MySQL Zend 框架 - SQLSTATE[42000]:语法错误或访问冲突:1064

2023-06-25数据库问题
10

本文介绍了MySQL Zend 框架 - SQLSTATE[42000]:语法错误或访问冲突:1064的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在发布这个问题之前,我已经阅读了所有我可以接受的回复.虽然相似,但没有一个解决我的特定问题(或者我没有意识到他们这样做).

I've read every response I could fine on SO before posting this question. Although similar, none addressed my particular problem (or I didn't recognize them doing so).

我有一个扩展 Zend_Db_Table_Abstract 的表类.在模型中,我尝试使用 join() 方法并基于如下表 ID 返回单行:

I have a table class that extends Zend_Db_Table_Abstract. In the model, I'm trying to return a single row using a join() method and based on the table ID like this:

        $getCategoryResults = $this->select();
        $getCategoryResults->setIntegrityCheck(false)
                           ->from(array('c'=> 'categories', '*'))
                           ->join(array('e' => 'events'),'c.events_idEvent = e.idEvent', array())
                            ->where("e.idEvent = ?", $idEvent);

当我回显 sql 对象时,我得到这个:

when I echo the sql object, I get this:

SELECT `c`.* FROM `categories` AS `c` 
INNER JOIN `events` AS `e` ON c.events_idEvent = e.idEvent 
WHERE (e.idEvent = '1')

奇怪的是,如果我使用这种格式,

Oddly enough, if I use this format,

->where("e.idEvent = $idEvent");

我的输出是WHERE (e.idEvent = 1)".该值未包含在刻度中,但似乎适用于 MySQL.当我在 phpMyAdmin 中运行查询时,我得到这个:

my output is "WHERE (e.idEvent = 1)". The value is not enclosed in ticks, but either seems to work for MySQL. When I run the query in phpMyAdmin, I get this:

idCategory type displayOrder description localStartTime events_idEvent
1 个人 1 5k 跑步/步行 2010-02-18 23:59:59 1
2 team 2 5k Team Category 2010-02-18 23:59:591 1

idCategory type displayOrder description localStartTime events_idEvent
1 individual 1 5k Run / Walk 2010-02-18 23:59:59 1
2 team 2 5k Team Category 2010-02-18 23:59:591 1

这是我期望看到的.但是当我在浏览器中运行我的应用程序时,我得到了这个丑陋:

which is what I expected to see. But when I run my app in a browser, I get this ugliness:

SQLSTATE[42000]:语法错误或访问冲突:1064 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 'SELECT c.* FROM categories AS c INNER JOIN <附近使用的正确语法code>events AS e ON c.events_id' 在第 1 行

SQLSTATE[42000]: Syntax error or access violation: 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 'SELECT c.* FROM categories AS c INNER JOIN events AS e ON c.events_id' at line 1

我已经检查了我能想到的所有资源.希望 SO 超级专家的结合使我成为最后一站.:D

I've checked every resource that I can think of. Hopefully, the combined awesomeness of SO uber-experts will make this my last stop. :D

推荐答案

查看错误语句的第二部分.如果 mysql 在其他地方,很可能是关于访问冲突.

Check out the second part of the error statement. Most likely it is regarding an access violation if the mysql elsewhere.

这篇关于MySQL Zend 框架 - SQLSTATE[42000]:语法错误或访问冲突:1064的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

MySQL GROUP BY DateTime +/- 3 秒
MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)...
2024-04-16 数据库问题
14