thinkphp3.1视图模型生成的SQL语句执行不了
在做一个订单系统,在用视图模型的时候打印不出东西。
自定义的视图模型
<?php<br />//订单视图<br /><br />Class OrderViewModel extends ViewModel{<br /> public $viewFields = array(<br /> 'order' => array('id','orderNo','date','money','memo','state','_type'=>'LEFT'),<br /> 'client' => array('clientName','_on'=>'order.client_id=client.id','_type'=>'RIGHT'),<br /> 'user' => array('userName','_on'=>'order.user_id=user.id'), <br /> );<br /> <br />}<br />?>
$Model = D("OrderView");<br /> $result = $Model->select();<br /> p($result);die;
SELECT order.id AS id,order.orderNo AS orderNo,order.date AS date,order.money AS money,order.memo AS memo,order.state AS state,client.clientName AS clientName,user.userName AS userName FROM or_order order LEFT JOIN or_client client ON order.client_id=client.id RIGHT JOIN or_user user ON order.user_id=user.id