Thinkphp view model query prompt: ERR: 1146: Table 'db. pr_order_view 'doesn' t exist solution, vieworder

Source: Internet
Author: User

Thinkphp view model query prompt: ERR: 1146: Table 'db. pr_order_view 'doesn' t exist solution, vieworder

This example describes the thinkphp view model query failure prompt: ERR: 1146: Table 'db. pr_order_view 'doesn' t exist solution. Share it with you for your reference. The specific method is as follows:

I. Problem description:

If you want to use the view model of thinkphp for associated queries, the following error occurs: ERR: 1146: Table 'db. pr_order_view 'doesn' t exist. I am wondering how the SQL statements of the view model come out. The view model is as follows:

Copy codeThe Code is as follows: class OrderViewModel extends ViewModel
{
Public $ viewFields = array (
'Order' => array (
'_ As' => 'Orders', // Rename to avoid conflicts with the system syntax.
'Id' => 'id ',
'Ordid ',
'User ',
'Product ',
'Status ',
'Paynum ',
'Cat ',
'Payment _ trade_no ',
'IP' => 'mip ',
'Reserve _ time ',
'Createtime ',
'Payment _ trade_status ',
),
'Member' => array (
'Id' => 'mid ',
'Name' => 'uname ',
'Cardnnum ',
'Tel ',
'Reg _ time ',
'Reg _ ip ',
'Qq ',
'Email ',
'Address ',
'Last _ login_time ',
'Last _ login_ip ',
'_ On' => 'Orders. user = Member. id'
),
'Product' => array (
'Id ',
'Your title ',
'Img1 ',
'Category ',
'_ On' => 'Orders. product = Product. id'
),
);
}
?>

Ii. solution:

I have read many manuals and Baidu, but I have not found a solution, and the call is not wrong. $ Form = D ('admin/orderview'); (I used groups here) after checking it myself, it turns out that there is a problem. The original view model name is wrong, OrderView. class. php. It should be OrderViewModel. class. php.

For beginners of ThinkPHP, pay special attention not to make such low-level mistakes!

I hope this article will help you with ThinkPHP framework programming.


Combined Query of three tables in the thinkphp view Model

It is not recommended to perform aggregation for connections, which is prone to problems. Generally, the user's consumption amount is directly synchronized. In other words, the user consumption table is separately created, the value of this field is added when the user consumes it.

Or separate your SQL room order and dining order. Otherwise, there will only be nesting. It seems unnecessary.

Thinkphp M method usage Problems

You pass the "Limit 1" and the M ("Limit 1") method to the class name. thinkphp converts the class name to the table name during query. The table prefix + _ uppercase letters and small letters
For example, if AbcDef is converted to the table name caiyy_abc_def, action = "/Index
/Addsoft/limit 1 ", the program has another error:
$ Form = M ($ soft); $ Form-> create ();
Here it should be D ($ soft); only the objects created by the D function have the create method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.