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

WBOY
Release: 2016-06-23 13:44:30
Original
1465 people have browsed it

模型里这么写的

<?phpnamespace 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'),    );}
Copy after login

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


返回的一些错误
["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();
Copy after login
Copy after login

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

# PicView 模型初始化,如果该PicView类存在则调用并初始化,如果不存在 ,则根据表名初始化模型         $PicModel =D('PicView'); #输出所有数据 实际执行的SQL语句是# SELECT * FROM PicView         $s =   $PicModel->select();
Copy after login
Copy after login

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


谢谢好心人 我已经解决了 就是两个表的字段排序不一样造成了  其他的还好 框架使用方便点
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!