【发布时间】:2010-06-10 21:29:29
【问题描述】:
我正在处理两个表(urls 和companies)的简单JOIN。我正在使用这个查询调用:
print $this->_db->select()->from(array('u' => 'urls'),
array('id', 'url', 'company_id'))
->join(array('c' => 'companies'),
'u.company_id = c.id');
提出这个查询:
SELECT `u`.`id`, `u`.`url`, `u`.`company_id`, `c`.* FROM `urls` AS `u` INNER JOIN `companies` AS `c` ON u.company_id = c.id
现在,我希望c.* 不实际出现,但无论哪种方式都无所谓。 ZF 死于此错误:
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 '' at line 1"
但我可以在我的 MySQL CLI 中完美地运行该查询。任何想法如何修复此查询?
【问题讨论】:
-
检查公司表中是否有保留关键字(字段)。 dev.mysql.com/doc/refman/5.1/en/reserved-words.html
标签: php mysql zend-framework