Why does the Zend Framework (Zend_Db_table) reject this SQL query?

I'm working on a simple JOINtwo tables ( urlsand companies). I am using this query:

print $this->_db->select()->from(array('u' => 'urls'),
                                 array('id', 'url', 'company_id'))
                          ->join(array('c' => 'companies'),
                                 'u.company_id = c.id');

which does not specify this request:

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 would prefer c.*not to actually appear, but in any case it does not 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 perfectly execute this query in my MySQL CLI. Any ideas on fixing this request?

+3
source share
1 answer

I just tried this code in a test script against ZF 1.10 and MySQL 5.1, and it works fine.

/ ? " ", , db . MySQL CLI, / ( , /).

. MySQL Zend Framework - SQLSTATE [42000]: :

Btw, c.*, join():

->join(array('c' => 'companies'), 'u.company_id = c.id', array());
+5

Source: https://habr.com/ru/post/1749486/


All Articles