Why is Zend Framework (Zend_Db_table) rejecting this SQL Query?
- by Michael T. Smith
I'm working on a simple JOIN of two tables (urls and companies). I am using this query call:
print $this->_db->select()->from(array('u' => 'urls'),
array('id', 'url', 'company_id'))
->join(array('c' => 'companies'),
'u.company_id = c.id');
which is out putting this query:
SELECT `u`.`id`, `u`.`url`, `u`.`company_id`, `c`.* FROM `urls` AS `u` INNER JOIN `companies` AS `c` ON u.company_id = c.id
Now, I'd prefer the c.* to not actually appear, but either way it doesn't matter. ZF dies with this error:
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"
but I can run that query perfectly fine in my MySQL CLI. Any ideas how to fix up this query?