Note that there are some explanatory texts on larger screens.

plurals
  1. POPropel find query in Symfony2 using "use"
    text
    copied!<p>I'm trying get from my database some informations with this Query :</p> <pre><code>$broadcastsQuery = BroadcastQuery::create() -&gt;limit(20); -&gt;useBroadcastPartQuery(null, \Criteria::INNER_JOIN) -&gt;useTopRelatedByIdTopBeginQuery(null, \Criteria::INNER_JOIN) -&gt;endUse() -&gt;useTopRelatedByIdTopEndQuery(null, \Criteria::RIGHT_JOIN) -&gt;endUse() -&gt;endUse() -&gt;filterBySended(true) -&gt;find(); </code></pre> <p>Here is the part of my schema.xml file with the concerned tables : </p> <pre><code>&lt;table name="broadcast"&gt; &lt;column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /&gt; &lt;column name="id_channel" type="integer" /&gt; &lt;column name="id_media" type="integer" /&gt; &lt;column name="start_at" type="timestamp" /&gt; &lt;column name="title" type="varchar" size="255" /&gt; &lt;column name="sended" type="boolean" /&gt; &lt;unique name="broadcast_id_plurimedia"&gt; &lt;unique-column name="id_plurimedia" /&gt; &lt;/unique&gt; &lt;foreign-key foreignTable="channel"&gt; &lt;reference local="id_channel" foreign="id" /&gt; &lt;/foreign-key&gt; &lt;/table&gt; &lt;table name="broadcast_part"&gt; &lt;column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /&gt; &lt;column name="id_broadcast" type="integer" /&gt; &lt;column name="id_top_begin" type="integer" /&gt; &lt;column name="id_top_end" type="integer" /&gt; &lt;foreign-key foreignTable="broadcast"&gt; &lt;reference local="id_broadcast" foreign="id" /&gt; &lt;/foreign-key&gt; &lt;foreign-key foreignTable="top"&gt; &lt;reference local="id_top_begin" foreign="id" /&gt; &lt;/foreign-key&gt; &lt;foreign-key foreignTable="top"&gt; &lt;reference local="id_top_end" foreign="id" /&gt; &lt;/foreign-key&gt; &lt;/table&gt; &lt;table name="top"&gt; &lt;column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /&gt; &lt;column name="id_channel" type="integer" /&gt; &lt;column name="genre" type="varchar" size="20" /&gt; &lt;column name="source" type="varchar" size="20" /&gt; &lt;column name="real_date" type="timestamp" /&gt; &lt;column name="frame" type="tinyint" /&gt; &lt;column name="title" type="varchar" size="255" /&gt; &lt;column name="orphan" type="boolean" /&gt; &lt;column name="type" type="varchar" size="10" /&gt; &lt;foreign-key foreignTable="channel"&gt; &lt;reference local="id_channel" foreign="id" /&gt; &lt;/foreign-key&gt; &lt;/table&gt; </code></pre> <p>When i'm trying to execute this query I received this error message :</p> <pre><code>...Syntax error or access violation: 1066 Not unique table/alias: "top"... </code></pre> <p>I know that I can use an alias for the 2nd use of the "top" table (useTopRelatedByIdTopEndQuery) but I can't find a way to do it.</p> <p>I'm also having another problem, when I try with only one use just to verify that I'm correctly retrieving datas from my DB I don't have any BroadcastPart inside my Broadcast object.</p> <p>Here is a dump of one of my Broadcast inside my collection :</p> <pre><code>[0] =&gt; Broadcast Object ( [startCopy:protected] =&gt; [id:protected] =&gt; 1 [id_channel:protected] =&gt; 328 [start_at:protected] =&gt; 2013-09-05 09:31:00 [title:protected] =&gt; Killo Design [sended:protected] =&gt; 1 [aChannel:protected] =&gt; [collBroadcastParts:protected] =&gt; [collBroadcastPartsPartial:protected] =&gt; [alreadyInSave:protected] =&gt; [alreadyInValidation:protected] =&gt; [alreadyInClearAllReferencesDeep:protected] =&gt; [broadcastPartsScheduledForDeletion:protected] =&gt; [validationFailures:protected] =&gt; Array ( ) [_new:protected] =&gt; [_deleted:protected] =&gt; [modifiedColumns:protected] =&gt; Array ( ) [virtualColumns:protected] =&gt; Array ( ) ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload