top-think / think

ThinkPHP Framework ——十年匠心的高性能PHP框架
http://www.thinkphp.cn
Other
7.83k stars 1.62k forks source link

模型实例化新增数据包含类型转换错误 #904

Open goofy-he opened 5 years ago

goofy-he commented 5 years ago

class AdvModel extends Model { protected $name = 'adv'; protected $type = [ 'pics_detail' => 'array', 'valid_time' => 'datetime', ];

实例化模型时插入数据,新增不上 $add = new AdvModel([ 'pics_detail'=> [ 'http://img95.699pic.com/photo/40100/4686.gif_wh300.gif', 'http://img95.699pic.com/photo/40100/4859.gif_wh300.gif', 'http://img95.699pic.com/photo/40100/7270.gif_wh300.gif' ], ]); $add->save(); 实例化后插入可以 $add = new AdvModel(); $add->save([ 'pics_detail'=> [ 'http://img95.699pic.com/photo/40100/4686.gif_wh300.gif', 'http://img95.699pic.com/photo/40100/4859.gif_wh300.gif', 'http://img95.699pic.com/photo/40100/7270.gif_wh300.gif' ], ]);

liu21st commented 5 years ago

实例化的时候传入的数据被认为是实际的数据,是不会经过修改器处理的,所以类型定义无效