The SQL statement generated by the thinkphp3.1 View model cannot be executed in an order system and cannot be printed when the view model is used.
Custom View model
Array ('id', 'orderno', 'date', 'Money', 'memo', 'State', '_ type' => 'left '), 'client' => array ('clientname', '_ on' => 'order. client_id = client. ID', '_ type' => 'right'), 'user' => array ('username',' _ on' => 'order. user_id = user. ID'),) ;}?>
Table structure
After the following statements are executed, a blank area is printed.
$Model = D("OrderView");$result = $Model->select();p($result);die;
After viewing the log file, the generated SQL statement is
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
Please help me. This is a design experiment at the end of the project. it will take a few days to complete. it is very urgent. thank you!
Reply to discussion (solution)
The automatic table prefix has been added to the config file.
What is the problem with the execution of the generated SQL statement?
What is the problem with the execution of the generated SQL statement?
Error message
1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left JOIN or_client client ON order. client_id = client. id right join or_user user 'at line 1
Do not use order for table aliases,
Order is the keyword ~
Do not use order for table aliases,
Order is the keyword ~
Thanks for your success.