【程式碼】thinkphp檢視模型查詢失敗提示:ERR: 1146:Table ‘db.pr_order_view’ doesn’t exist
阿新 • • 發佈:2019-01-31
想用thinkphp的檢視模型進行關聯查詢,結果出現了這樣兒的問題(log日誌記錄):ERR: 1146:Table 'db.pr_order_view' doesn't exist,我就納悶兒,檢視模型怎麼出來的sql是這樣兒的呢,檢視模型如下:
/** * 訂單檢視模型 order 連線 member 連線 product * * @version $Id: OrderViewModel.class.php * @author zone QQ:2408198675 * @date 2013-8-1 * @link http://www.tsingyuan.cn */ class OrderViewModel extends ViewModel { public $viewFields = array( 'Order'=>array( '_as'=>'Orders', //重新命名,以免與系統語法衝突 (PS:^_^不錯的php開發學習交流群:256271784,驗證:csl,有興趣的話可以加入進來一起討論) 'id'=>'oid', 'ordid', 'user', 'product', 'status', 'paynum', 'cat', 'payment_trade_no', 'ip'=>'mip', 'reserve_time', 'createtime', 'payment_trade_status', ), 'Member'=>array( 'id'=>'mid', 'name'=>'uname', 'cardnum', 'tel', 'reg_time', 'reg_ip', 'qq', 'email', 'address', 'last_login_time', 'last_login_ip', '_on'=>'Orders.user=Member.id' ), 'Product'=>array( 'id', 'shorttitle', 'img1', 'category', '_on'=>'Orders.product=Product.id' ), ); } ?>
看了手冊及百度了很多,沒有找到解決方案,呼叫也沒有錯$Form = D('Admin/OrderView');(這裡我用了分組)經過我自己檢視,原來是有問題的,原來檢視模型的名字命名錯了,唉,OrderView.class.php,正常應該是 OrderViewModel.class.php 唉,太粗心了,希望朋友們不要犯這樣兒的低階錯誤~\(≧▽≦)/~啦啦啦!