On 2/20/07, Кононов Руслан <[EMAIL PROTECTED]> wrote:
Hi, all.
in ZF 0.7 my query work fine, but not in 0.8rc1.
$select = $db->select();
$select->from('journal', array('journal_id','journal_group_id',
'journal_user_id', 'journal_title','journal_ts_add') );
$select->joinLeft('users u', 'journal_user_id = u.user_id',
array('u.user_surname','u.user_name','u.user_otch') );
$select->joinLeft('users e', 'journal_execute_id = e.user_id',
array('e.user_surname AS execute_surname') );
$select->joinLeft('journal_groups', 'journal_group_id =
journal_groups_id', array('journal_groups_title') );
Full query from ZF 0.7 profiler :
*SELECT
journal_id,
journal_group_id,
journal_user_id,
journal_title,
journal_ts_add,
u.user_surname,
u.user_name,
u.user_otch,
e.user_surname AS execute_surname,
journal_groups_title
FROM
journal
LEFT JOIN users u ON journal_user_id = u.user_id
LEFT JOIN users e ON journal_execute_id = e.user_id
LEFT JOIN journal_groups ON journal_group_id = journal_groups_id
In ZF 0.8 i'm get error :
*string(282) "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 '.`u.user_surname`,
users u.`u.user_name`, users u.`u.user_otch`, users e.`e.u' at line 7"
What problem ?
It seems that ZF 0.8 adds `...` for field names so that makes impossible
using of 'u.user_surname' constructions.
I think that $select->joinLeft(array('users' => 'u'), ...) ); should be
available soon.
--
Alexander
http://www.alexatnet.com/