This article describes the example of thinkphp view model query failure prompt: ERR: 1146: Table 'db.pr_order_view' doesn't exist solution. Share it with everyone for your reference. The specific method is as follows:
1. Problem description:
I want to use thinkphp's view model to perform related queries, but the result is this problem (log record): ERR: 1146: Table 'db.pr_order_view' doesn't exist, I wonder how the view model comes out of sql That’s it, the view model is as follows:
2. Solution:
I read a lot of manuals and Baidu, but I didn’t find a solution, and there was nothing wrong with calling $Form = D('Admin/OrderView'); (I used grouping here). After checking it myself, it turned out that there was a problem. It turns out that the name of the view model is wrong, OrderView.class.php, it should be OrderViewModel.class.php normally.
ThinkPHP beginners should especially be careful not to make such low-level mistakes!
I hope this article will be helpful to everyone’s ThinkPHP framework programming.
It is not recommended to perform aggregation operations on connections, as it is easy to cause problems. Generally, the user's consumption amount is directly synchronized. In other words, there is a separate user consumption table, and the value of this field is increased when the user consumes. .
Or write your sql room order and catering order separately, otherwise it will only be nested, which seems not necessary
What you passed is "RJ1". The M method M ("RJ1") passes the class name. Thinkphp will convert the class name into a table name when querying. The rule is the table prefix + _uppercase letters and lowercase letters
+ _uppercase letters and lowercase letters. For example, if AbcDef is converted into a table name, it is caiyy_abc_def. If it is changed to lowercase, there will be no problem. action="/Index
/ addsoft/rj1", there is another error in the program:
$Form =M($soft);$Form->create();
This should be D($soft); only objects created by the D function There is a create method.