视图模型 PicViewModel.class.php
<?php
namespace Home\Model;
use Think\Model\ViewModel;
class PicViewModel extends ViewModel{
public $viewFields =array(
'picture'=> array('picTitle','picToken','picCategroy','picAuthor','picPostTime'),
'picture_attachment' =>array('pictureid','pictureurl','creattime','_on'=>'picture.picToken = picture_attachment.pictureid'),
);
}
控制器里的方法 public function Pic(){
$PicModel =D('PicView');
dump($PicModel);
$s = $PicModel->field('picTitle,picCategroy,picAuthor,picPostTime,pictureurl')->order('picPostTime DESC')->select();
dump($s);
}
查询出来就是bool(false) 不知道是不是表名的问题呢 这个是正确的表前缀["tablePrefix":protected]
还是看下面的 ["model":protected] 这个呢?
["db":protected] => ob
["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) ""
["li
}
["_li
["queryID":protected] => NULL
["connected":protected] => bool(false)
["autoinc":protected] => bool(false)
["patchValidate":protected] => bool(false)
看了好几遍手册感觉还是不能理解? 求指点 ~
最佳答案
