Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am not certain of the best way to do this with Propel, but a way I just recently did was to do 2 separate queries, using a select on the first one to only get Id's. This query returns an array of Id's which can then be passed to the second query. It is less efficient than a single DB call, but the code is pretty easy to read (bear with me, this is my first attempt to get some code into an answer) </p> <p>Here is a quick tested example from the location I happend to be working in in my own codebase:</p> <pre><code>$posts = PostsQuery::create()-&gt;select('Id')-&gt;filterByDeleted(ACTIVE_RECORD)-&gt;filterByPostTypeId($postType-&gt;getId())-&gt;limit(5)-&gt;find()-&gt;toArray(); $posts2 = PostsQuery::create()-&gt;filterById($posts)-&gt;find(); </code></pre> <p>the first object ($posts) is:</p> <pre><code>array(5) {\n [0]=&gt;\n string(3) "374"\n [1]=&gt;\n string(3) "375"\n [2]=&gt;\n string(3) "376"\n [3]=&gt;\n string(3) "377"\n [4]=&gt;\n string(3) "378"\n}\n </code></pre> <p>...and the second is the full 5 rows.</p> <p>Disclaimer for this being a simplified example that originally was just a paginated query: </p> <pre><code>$posts = CmsPostsQuery::create()-&gt;filterByDeleted(ACTIVE_RECORD)-&gt;filterByPostTypeId($postType-&gt;getId())-&gt;paginate($pageNum,10); </code></pre> <p>I stumbled across a better answer for you at: <a href="https://stackoverflow.com/questions/7892354/orm-solution-for-really-complex-queries">ORM Solution for really complex queries</a></p>
 

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