search
Homephp教程php手册thinkphp视图模型查询提示ERR: 1146:Table 'db.pr_order_view' doesn't e

这篇文章主要介绍了thinkphp视图模型查询提示ERR: 1146:Table

本文实例讲述了thinkphp视图模型查询失败提示:ERR: 1146:Table 'db.pr_order_view' doesn't exist解决办法。分享给大家供大家参考。具体方法如下:

一、问题描述:

想用thinkphp的视图模型进行关联查询,结果出现了这样的问题(log日志记录):ERR: 1146:Table 'db.pr_order_view' doesn't exist,我就纳闷,,视图模型怎么出来的sql是这样的呢,视图模型如下:

复制代码 代码如下:

class OrderViewModel extends ViewModel
{
public $viewFields = array(
'Order' =>array(
'_as'=>'Orders', //重新命名,以免与系统语法冲突
'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'
),
);
}
?>

二、解决方法:

看了手册及百度了很多,没有找到解决方案,调用也没有错$Form = D('Admin/OrderView');(这里我用了分组)经过我自己查看,原来是有问题的,原来视图模型的名字命名错了,OrderView.class.php,正常应该是 OrderViewModel.class.php。

对于ThinkPHP初学者来说尤其要注意不要犯这样的低级错误!

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.