thinkphp 3.2 視圖模型 查詢 出來bool(false) 求解解決方案

來源:互聯網
上載者:User
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初學者不建議直接看架構!

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.