MySQL Zend Framework - SQLSTATE[42000]: Syntax error or access violation: 1064(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.* FROMcategoriesAScINNER JOINeventsASeON 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL Zend 框架 - SQLSTATE[42000]:语法错误或访问冲突:1064
				
        
 
            
        基础教程推荐
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
 - 从字符串 TSQL 中获取数字 2021-01-01
 - 带更新的 sqlite CTE 2022-01-01
 - while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
 - 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
 - MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
 - MySQL 5.7参照时间戳生成日期列 2022-01-01
 - 带有WHERE子句的LAG()函数 2022-01-01
 - ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
 - 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				