Home  >  Article  >  Backend Development  >  thinkphp 3.2 视图模型 查询 出来bool(false) 求解解决方法

thinkphp 3.2 视图模型 查询 出来bool(false) 求解解决方法

WBOY
WBOYOriginal
2016-06-13 12:10:281368browse

thinkphp 3.2 视图模型 查询 出来bool(false) 求解
模型里这么写的

<?php<br />namespace Home\Model;<br />use Think\Model\ViewModel;<br />class PicViewModel extends  ViewModel{<br />    public $viewFields =array(<br />       'picture'=> array('picTitle','picToken','picCategroy','picAuthor','picPostTime','_type'=>'LEFT'),<br />        'picture_attachment' =>array('pictureid','pictureurl','creattime','_on'=>'picture.picToken = picture_attachment.pictureid'),<br /><br />    );<br />}

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


返回的一些错误
["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)
------解决思路----------------------
<br /># PicView 模型初始化,如果该PicView类存在则调用并初始化,如果不存在 ,则根据表名初始化模型<br />         $PicModel =D('PicView');<br /> <br />#输出所有数据 实际执行的SQL语句是<br /># SELECT * FROM PicView<br />         $s =   $PicModel->select();<br />

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn