thinkphp view model query hint err:1146:table ' db.pr_order_view ' doesn ' t exist workaround, vieworder_php tutorial

Source: Internet
Author: User

thinkphp view model query hint err:1146:table ' db.pr_order_view ' doesn ' t exist workaround, Vieworder


This example describes the Thinkphp view model query failure prompt: Err:1146:table ' db.pr_order_view ' doesn ' t exist solution. Share to everyone for your reference. Here's how:

First, the problem description:

Want to use the thinkphp view model to correlate the query, the result is such a problem (log logging): err:1146:table ' db.pr_order_view ' doesn ' t exist, I wondered how the view model out of SQL is like this, The view model is as follows:

Copy the Code code as follows: Class Orderviewmodel extends ViewModel
{
Public $viewFields = Array (
' Order ' =>array (
' _as ' + ' Orders ',//renamed to avoid conflicts 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 '
),
);
}
?>

Second, the solution:

Read the manual and Baidu a lot, did not find a solution, the call is not wrong $form = D (' Admin/orderview '); (I used a group here) through my own view, the original is problematic, the original view model name is wrong, OrderView.class.php, normal should be OrderViewModel.class.php.

For thinkphp beginners, be especially careful not to make such a low-level error!

It is hoped that this article will be helpful to everyone's thinkphp framework design.


thinkphp View Model 3-Sheet Union query

The connection is not recommended to do the aggregation operation, it is easy to trouble, generally this is directly synchronize the user's consumption amount, in other words, is a separate user consumption table, users have to increase the value of this field when spending.

Or put your SQL room orders and catering orders separately, or only nested, there seems to be no need for this

thinkphp m method Usage issues

You preach "RJ1", M ("RJ1") This m method incoming is the class name, thinkphp will convert the class name to the table name when querying. The return is the table prefix +_ uppercase and lowercase
Female +_ uppercase and lowercase letters, such as ABCDEF conversion to table name is Caiyy_abc_def, if you change to lowercase it will be fine action= "/index
/addsoft/rj1 ", the program also has a little error:
$Form =m ($soft); $Form->create ();
This should be d ($soft); only objects created by the D function have the Create method.

http://www.bkjia.com/PHPjc/903485.html www.bkjia.com true http://www.bkjia.com/PHPjc/903485.html techarticle thinkphp View model query hint err:1146:table ' db.pr_order_view ' doesn ' t exist workaround, Vieworder This example describes the Thinkphp view model query failure prompt: ERR: 1146: ...

  • Related Article

    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.