#1483: Cannot perform sub-queries that relate to the query
-----------------------------------+----------------------------------------
 Reporter:  colnector              |       Owner:  romanb
     Type:  defect                 |      Status:  new   
 Priority:  major                  |   Milestone:        
Component:  Query/Hydration        |     Version:  1.0   
 Keywords:                         |    Has_test:  0     
 Mystatus:  Pending Core Response  |   Has_patch:  0     
-----------------------------------+----------------------------------------
 In relation to this ticket http://trac.doctrine-
 project.org/ticket/1396#comment:7


 This is the part that now works (assume $table = 'Phrase' before):
                   ->leftJoin("$table.Translation t2_$table WITH
 t2_$table.lang = 0 INDEXBY t2_$table.lang")
                   ->leftJoin("$table.Translation t_$table WITH
 t_$table.lang = '$language' INDEXBY t_$table.lang")

 and I'm trying to go for something like
 ->leftJoin("$table.Translation t_$table WITH t_$table.lang = (SELECT
 MAX(t2_$table.lang) FROM $table.Translation t2_$table WHERE
 (t2_$table.lang='$language' OR t2_$table.lang='0') AND
 t2_$table.id=t_$table.id) INDEXBY t_$table.lang")

 But am getting a syntax 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
 Because the DQL statement is erroneously written as:
 Doctrine_Connection->execute('SELECT p.id AS p__id, p.original AS
 p__original, p.context AS p__context, p2.id AS p2__id, p2.lang AS
 p2__lang, p2.name AS p2__name FROM phrase p LEFT JOIN phrase_translation
 p2 ON p.id = p2.id AND p2.lang = (SELECT MAX(t2_p.lang) FROM p.Translation
 t2_p WHERE (t2_p.lang='45' OR t2_p.lang='0')', array())

 The underlined part should have been phrase_translation

 So though I tried to workaround it, there are other parts later that I
 cannot workaround since it seems the sub-query is completely unaware of
 the main query thus cannot use its aliases.

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1483>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to