Why is Zend Framework (Zend_Db_table) rejecting this SQL Query?

Posted by Michael T. Smith on Stack Overflow See other posts from Stack Overflow or by Michael T. Smith
Published on 2010-06-10T21:29:29Z Indexed on 2010/06/10 21:32 UTC
Read the original article Hit count: 164

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql