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

### Bug 一对一关联保存时,关联表数据保存成功后,当前模型主键并未传过去。 ### 版本 ![image](https://user-images.githubusercontent.com/20442232/135018941-ab5ab632-6078-475e-99a0-8324ed962a62.png) ### 我的代码 ``` // 主表定义的关联模型 public function admin() { return $this->hasOne(Users::class,'staff_id','userid'); } // 控制器测试代码 public function test() { // StaffModel->$pk = userid 主键是userid $staff...

mongo配置默认pk_convert_id=false 模型查询后 默认pk='id' 这样导致模型的save可能会更新多条数据 比如我有一个数据集 test 部分字段允许重复 比如title 定义了模型为`Test` 先查询一条数据,该条件下有多条数据,仅查第一条 ``` $data = Test::where('title','hello')->findOrEmpty(); ``` ``` db.test.find({title:"hello"}).limit(1) ``` 然后对数据进行了更新操作 ``` $data = Test::where('title','hello')->findOrEmpty(); $data->version = 2; $data->save(); ``` 本来以为仅更新了查询出来的那条数据,后来发现title=hello的都被修改了,看了一下sql日志发现更新条件和查询条件是一样的 ```...

MongoDb

1、hasOneThrough使用bind后,报错 代码片段1: ``` public function hasOneThroughGoodsDetail() { return $this->hasOneThrough(KypGoodsDetail::class,KypGoods::class,'id','id','goods_id','goods_warehouse_id') ->bind([ 'goods_detail_id' =>'goods_warehouse_id', 'goods_name'=>'name', 'goods_cover_pic'=>'cover_pic', ]); } ``` 2、直接在控制器使用bindAttr,name字段没有调用正确的数据,而是显示对应模型的表名$name字段的值 代码片段2: ``` $goodsList = BlindboxGoodsModel::with(['hasOneGoods','hasOneThroughGoodsDetail']) ->where('blindbox_id',$params['id']) ->find() ->bindAttr('hasOneThroughGoodsDetail',['goods_name' =>'name']); ``` 代码片段3:GoodsDetail模型代码 ```...

现在最新2.06版 think-cache get方法默认返回false了, public function get($name, $default = false) 然后PDOConnection 694行那缓存判断是null if (null !== $data ) { return $data; } 导致没缓存一样把$data返回去了,报错: Return value must be of type array, bool returned...

ShopGoodsspecModel::where('goods_type_id','=',‘1’)->order('list_order asc,goods_spec_id asc')->select(); dump后输出类似json的数据,不是原来的think\model\Collection "[("goods_ spec_ id" :30, "goods_ type id":37)]"

是不是应该加一次$count判断 ``` $total = count($resultSet); while ($total > 0) { if (false === call_user_func($callback, $resultSet)) { return false; } if ($total < $count) { return true; } }

设定了 JsonJob 类 JsonJob.php ``` namespace app\common\model; use think\Model; class JsonJob extends Model { protected $jsonAssoc = true; protected $json = ['data']; // 设置JSON字段的类型 protected $jsonType = [ 'data->vod_id' =>...

![image](https://user-images.githubusercontent.com/13957066/88776506-a0316200-d1b8-11ea-8acb-7954ef0eb95b.png) 可以加其他参数使得能够查询指定字段嘛?

@liu21st 这是什么原因改了啊,现在产生兼容问题了。 ``` (new \app\Model\TestModel()) ->field(['create_time', new \think\db\Raw('id + 1 as test')]) ->limit(10) ->select(); (new \app\Model\TestModel()) ->where('create_time', '=', new \think\db\Raw('1+1')) ->limit(10) ->select(); (new \app\Model\TestModel()) ->where([ ['create_time', '=', new \think\db\Raw('1 +...