当前位置:Gxlcms > PHP教程 > thinkphp3.2视图模型查询出来bool(false)求解解决方法

thinkphp3.2视图模型查询出来bool(false)求解解决方法

时间:2021-07-01 10:21:17 帮助过:17人阅读

thinkphp 3.2 视图模型 查询 出来bool(false) 求解
模型里这么写的
namespace Home\Model;
use Think\Model\ViewModel;
class PicViewModel extends ViewModel{
public $viewFields =array(
'picture'=> array('picTitle','picToken','picCategroy','picAuthor','picPostTime','_type'=>'LEFT'),
'picture_attachment' =>array('pictureid','pictureurl','creattime','_on'=>'picture.picToken = picture_attachment.pictureid'),

);
}

picture和picture_attachment两张表
控制器里这么写的 我用D方法实例化PicView 这个是必须在数据库里真实的表名么
    public function  Pic(){
$PicModel =D('PicView');

dump($PicModel);
$s = $PicModel->select();
dump($s);

}


返回的一些错误
["db":protected] => object(Think\Db\Driver\Mysql)#8 (19) {
["dbType":protected] => NULL
["autoFree":protected] => bool(false)
["model":protected] => string(7) "_think_"
["pconnect":protected] => bool(false)
["queryStr":protected] => string(0) ""
["modelSql":protected] => array(0) {
}
["lastInsID":protected] => NULL
["numRows":protected] => int(0)
["numCols":protected] => int(0)
["transTimes":protected] => int(0)
["error":protected] => string(0) ""
["linkID":protected] => array(0) {
}
["_linkID":protected] => NULL
["queryID":protected] => NULL
["connected":protected] => bool(false)
["autoinc":protected] => bool(false)
["patchValidate":protected] => bool(false)
------解决思路----------------------

# PicView 模型初始化,如果该PicView类存在则调用并初始化,如果不存在 ,则根据表名初始化模型
$PicModel =D('PicView');

#
输出所有数据 实际执行的SQL语句是
# SELECT * FROM PicView
$s = $PicModel->select();

PHP初学者不建议直接看框架!

人气教程排行