Solution to thinkphp View Model Query Hint ERR: 1146: Table 'db. pr_order_view' doesn 't exist

  • 2021-07-22 09:24:27
  • OfStack

This article illustrates the thinkphp view model query failure hint: ERR: 1146: Table 'db. pr_order_view' doesn 't exist solution. Share it for your reference. The specific methods are as follows:

1. Problem description:

I want to use the view model of thinkphp for association query, and the result is such a problem (log logging): ERR: 1146: Table 'db. pr_order_view' doesn 't exist, so I wonder how the view model came out of sql like this. The view model is as follows:

class OrderViewModel extends ViewModel
{
public $viewFields = array(
'Order' =>array(
'_as'=>'Orders', // Rename so as not to conflict with system syntax
'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'
),
);
}
?>

2. Solution:

After reading the manual and Baidu a lot, I didn't find a solution, and there was nothing wrong with calling $Form = D ('Admin/OrderView'); (I used grouping here) After my own inspection, it turned out to be problematic. The original view model was named incorrectly, OrderView. class. php, which should normally be OrderViewModel. class. php.

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

I hope this article is helpful to everyone's ThinkPHP framework programming.


Related articles: