think-orm icon indicating copy to clipboard operation
think-orm copied to clipboard

Think ORM——the PHP Database&ORM Framework

Results 251 think-orm issues
Sort by recently updated
recently updated
newest added

当模型类名和真实表名有差异的时候,会导致使用一对一、一对多关联查询里的 ``has`` 或者 ``hasWhere`` 方法获取不到真实的表名。 ![image](https://user-images.githubusercontent.com/2304019/137244649-2e9d3fab-211b-4653-8dcb-e22646ff085a.png) 如上图,模型类名 ``ZsBallRace``,而真实表名是模型的 ``$table`` 成员定义的 ``ball_race``,就会导致使用 ``has`` 或者 ``hasWhere`` 时报错。

``` php $data = [ 'name'=>$param['name'], 'phone'=>$param['phone'], 'time'=>date('Y/m/d H:i:s' ,time()) ]; Db::table('CUSTOMER')->strict(false)->insert($data); ``` 执行插入的时候就会报错: `SQLSTATE[HY000]: General error: 1861 OCIStmtExecute: ORA-01861: 文字与格式字符串不匹配` 尝试使用http://www.thinkphp.cn/topic/27014.html 这个方法 也不行 请教下该怎么处理time数据啊?

Oracle

查询oracle数据库的时候: 使用Db::table或模型查询比较慢,接口查询100条记录并返回数据要4秒,不知道是为什么,使用原生查询就很快(毫秒级返回数据) ``` php Db::table('lbd_customer')->where('rownum', '

Oracle

1.mongdb 未填写dsn的情况下,无法指定某个数据库 ![Snipaste_2021-10-20_18-09-51](https://user-images.githubusercontent.com/22142457/138074192-127c9032-f8dc-4966-b0c2-a62c7314b5c4.png) 2.部署方式为单一服务器模式一下,保存数据会出现 `MongoDB\Driver\Exception\BulkWriteException : Transaction numbers are only allowed on a replica set member or mongos` 建议在think\db\connector\Mongo 类的 transaction 方法判断是否为单一服务器模式 如果是单一模式 不生成相关事务

MongoDb

修复在使用model时不能使用group方法的问题

对于下面这段代码,对比`$data`和`$origin`,这两个应当是不一样的,但是原有代码认为这两个数据没有变换, 原因是`return is_object($a) || $a != $b ? 1 : 0;`, 这里的比较应该用强等于, ``` $data = [ 'date'=>'2019' ]; $origin = [ 'date'=>'2019.' ]; $result = array_udiff_assoc($data, $origin, function ($a, $b)...

模型的`data()`方法,建议不要直接用参数`$data`赋值到`$this->data `上,这样会导致调用`data()`方法之前的赋值丢失. `vendor\topthink\think-orm\src\model\concern\Attribute.php` ``` public function data(array $data, bool $set = false, array $allow = []) { // 清空数据 $this->data = []; // 废弃字段 foreach ($this->disuse as $key) { if...

下面这段代码不够严谨,希望能够处理一下 ![image](https://user-images.githubusercontent.com/24455112/106084498-6e925700-6159-11eb-99ac-3737ff2cda7b.png) PDOConnection public function transaction(callable $callback) { $this->startTrans(); try { $result = null; if (is_callable($callback)) { $result = $callback($this); } $this->commit(); return $result; } catch (\Exception | \Throwable $e)...

示例: $gname = 'group'; $data = $data->dictionary(null, $gname); dictionary的第二个参数string &$indexKey = null,采用引用传值,实际代码中没有对这个参数做任何改变,故不需要引用。 虽然没有任何问题,但调用时必须传入变量,影响代码简洁,望采纳改进

### 测试代码: ``` /** * 测试1 - 不做任何验证 */ public function test1() { // 查询列表 $query = AftersaleModel::with([ // 销售明细 'sales' => function($query) { // // 为前端售后单详细提供支持... // $query->with([ //...