记录的日志为:
[ info ] [ RUN ] app\api\controller\v1\Banner->getBanner[ E:\www\zerg\application\api\controller\v1\Banner.php ]
[ info ] [ DB ] INIT mysql
[ info ] [ LOG ] INIT File
[ sql ] [ DB ] CONNECT:[ UseTime:0.001000s ] mysql:dbname=zerg;host=127.0.0.1;port=3306;charset=utf8
[ sql ] [ SQL ] SHOW COLUMNS FROM `banner` [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT * FROM `banner` WHERE `id` = 1 LIMIT 1 [ RunTime:0.001000s ]
[ sql ] [ SQL ] SHOW COLUMNS FROM `banner_item` [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT * FROM `banner_item` WHERE `banner_id` = 1 [ RunTime:0.000000s ]
[ sql ] [ SQL ] SELECT * FROM `banner_item` WHERE `banner_id` = 1 [ RunTime:0.001000s ]
[ sql ] [ SQL ] SHOW COLUMNS FROM `image` [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT * FROM `image` WHERE `id` IN (65,2,3,1) [ RunTime:0.000000s ]
数据库是有对应的4张 图片的,为何查询结果最后一个img为null,断点调试BaseModel的prefixImgUrl($value,$data)方法只执行了3次,是什么原因
最后问题已经解决,原因是
V5.0.5+版本开始,默认使用IN查询方式,如果需要改为JOIN查询方式
// 设置预载入查询方式为JOIN方式
return $this->hasOne('Profile')->setEagerlyType(0);
解决办法如下: