think-orm
think-orm copied to clipboard
Think ORM——the PHP Database&ORM Framework
[BelongsToMany.php#L105 传递参数错误](https://github.com/top-think/think-orm/blob/v1.2.17/src/model/relation/BelongsToMany.php#L105) ```error TypeError: Argument 1 passed to think\model\Pivot::__construct() must be an instance of think\Model or null, array given ```
代码位置 :\topthink\think-orm\src\db\BaseQuery.php 原代码: ``` public function field($field) { if (empty($field)) { return $this; } elseif ($field instanceof Raw) { $this->options['field'][] = $field; return $this; } if (is_string($field)) { if (preg_match('/[\fieldRaw($field);...
老版有个问题,如果有全局查询范围或是添加了额外的条件,则会丢失主键条件 如: ``` $model = Model::find(1); $model->inc('field', 2)->where([ 'other' => 'value' ])->update(); ``` 这个更新的SQL会变成 `update model set field = field + 2 where other = value`,如果有个全局查询范围也会导致这样的情况,这样的行为结果有点反直觉反人类。 我不知道这样改下有没有其它影响,可以当作一个改进提议。
public function log(string $log, string $type = 'sql') { if ($this->log) { $this->log->log($type, $log); } else { $this->dbLog[$type][] = $log; } } 这段代码中,当有 $this->log时,日志就无法进入$this->dbLog 实际使用中,$this->log 由facade初始化默认有。除非重新set。 这与文档说明的支持的多通道有些差异。 建议调整为: public function...
数据写入 类型转换 如果使用自定义类来处理模型数据时,建议如果写入数据不是对象的时候直接初始化对象,不然使用模型存入数据时getChangedData调用的变化值不一定是对象期待的值 
 
从tp3.2到现在的tp6 一直使用着。 中间因为公司的原因,也使用过其他框架。 只说下tp不太完美的地方的吧. 对比yii2 1 在使用hasOne关联时,无法一直递归下去。 场景 小区表 id 小区名 单元表 id 小区id 单元名 楼栋表 id 单元ID 楼栋名 房号表 id 楼栋ID 房号 用户表 id 用户名 用户与房号关系表 id user_id house_id...
今天composer update了一下, 突然发现系统登录不了了, debug半天发现是 think\session\Store 序列化报错了 报错内容: ``` Serialization of 'Closure' is not allowed ``` 试了一下Cache果然也是报这个... `v2.0.47` 和 `v2.0.46` 这两版本都有这个问题
When I'm using Postgres database got error ``` think\db\exception\PDOException: SQLSTATE[42883]: Undefined function: 7 ERROR: function table_msg(unknown) does not exist LINE 1: ...fault as "default",fields_default as "extra" from table_msg(... HINT: No...
vendor/topthink/think-orm/src/db/Builder.php:155 154 } elseif (!is_scalar($val) && (in_array($key, (array) $query->getOptions('json')) || 'json' == $query->getFieldType($key))) { 155 $val = json_encode($val,JSON_UNESCAPED_UNICODE); 156 }