在简单的cakePHP设置中的SQL错误1064 [英] SQL error 1064 in simple cakePHP setup

查看:80
本文介绍了在简单的cakePHP设置中的SQL错误1064的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最简单的控制器和模型,如下所示:

I am using the simplest controller and model as shown here:

http://book.cakephp.org/view/1341/Basic-Usage

但是当我去 www.mysite.com/categories
导致的代码是:

But when i go to www.mysite.com/categories the code that causes it is:

<?php
class CategoriesController extends AppController {

    var $name = 'Categories';

    function index() {
        $this->data = $this->Category->generatetreelist(null, null, null, '&nbsp;&nbsp;&nbsp;');
        debug ($this->data); die;       
    }
}
?>

我得到以下错误:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recover' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
Code | Context

            $out = null;
            if ($error) {
                trigger_error('<span style="color:Red;text-align:left"><b>' . __('SQL Error:', true) . "</b> {$this->error}</span>", E_USER_WARNING);

$sql    =   "recover"
$error  =   "1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recover' at line 1"
$out    =   null

DboSource::showQuery() - CORE/cake/libs/model/datasources/dbo_source.php, line 684
DboSource::execute() - CORE/cake/libs/model/datasources/dbo_source.php, line 266
DboSource::fetchAll() - CORE/cake/libs/model/datasources/dbo_source.php, line 410
DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php, line 364
Model::call__() - CORE/cake/libs/model/model.php, line 502
Overloadable::__call() - CORE/cake/libs/overloadable_php5.php, line 50
AppModel::recover() - [internal], line ??
CategoriesController::index() - APP/controllers/categories_controller.php, line 7
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83

Query: recover

app/controllers/categories_controller.php (line 8)



我完全感到困惑,

I am totally confused, since I just copy-pasted from the original cakephp cookbook tutorial.

我有:
controllers / categories_controller.php
models / category_model.php
代码是从教程的复制粘贴。

I have: controllers/categories_controller.php models/category_model.php and the code is copy paste from the tutorial.

任何帮助?

推荐答案

问题解决。误差模型文件。
它是:category_model.php
应该是:category.php =(

Problem solved. Misnaming the model file. It Was: category_model.php Should have been: category.php =(

这篇关于在简单的cakePHP设置中的SQL错误1064的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆