Ok, probably did not explain myself very well then. I receive an array of panel Ids that I know have "issues", but since the panels are only parts of a bigger thing that is a furniture, I'm not interested in showing anyone that those panel have issues, I'd rather show that the bigger furniture as a whole has issues.
Therefore, upon receiving that list of troubled panels, I want to get all the related furniture (each panel has one and only one furniture) and display it later. The model is something like: furniture: id: other_non_relevant_columns: panel: id: furniture_id: other_non_relevant_stuff: The solution you just described here works, but as you said it's an ugly cheat (still looking better than the one I'm currently using though!) 2010/8/27 Georg <geor...@have2.com> > Actually I do not understant what you want to do. You have a group of > panels, and want to find a group of furniture so that no panel is > without furniture. But I can't image what you want to do with this > information without the relation to each panel. > > I have no good solution for your problem, only an ugly cheat :-( > > $pids = array(1,7,8,9); > Doctrine_Query::create()->from('Furniture f')->where('f.id IN (SELECT > pa.furniture_id FROM Panel pa WHERE pa.id IN ('.implode(', ', > array_fill(0, count($pids), '?').') )', $pids); > > Am 27.08.2010 05:05, schrieb Sebastien Armand [Pink]: > > It wouldn't be whereIn('f.id <http://f.id>', array(1,7,8,9)), because > > 1,7,8,9 are the ids of the panels. > > So I tried fetching the first request as an array (that I did hope would > > be an array of Ids) and using that array in whereIn('f.id > > <http://f.id>', $furnitureIdArray) > > But it turns out this array is like this: [ 0 => [ 'id' => '1' , > > 'furniture_id' => 7 ] , 1 => [ 'id' => '8' , 'furniture_id' => 79 ] ] > > So the only solution I found from there was to go through that whole > > array and build an array where I only have the furniture ids for my > > second request. > > > > Still I don't like that solution in that: > > - I have to query the DB 2 times instead of using a subquery > > - I have to loop through my first query results to build the arguments > > of the second query. > > - Something seems pretty wrong in here when I do all this! > > > > 2010/8/26 Georg <geor...@have2.com <mailto:geor...@have2.com>> > > > > try whereIn('f.id <http://f.id>', array(1,7,8,9)) > > > > Am 26.08.2010 11:12, schrieb Sebastien Armand [Pink]: > > > 'IN' being one of the worst possible keyword to search online ever, > I > > > found nothing interesting to solve my problem, so here it goes: > > > > > > My query should look something like this: > > > > > > Doctrine_Query::create()->from('Furniture f')->where('f.id > > <http://f.id> <http://f.id> > > > IN (SELECT pa.furniture_id FROM Panel pa WHERE pa.id > > <http://pa.id> <http://pa.id> IN ? > > > )', array(array(1,7,8,9)); > > > > > > so each 'furniture' has many panels, and a panel has a > furniture_id. I > > > received a list of panel ids and want to get all the furnitures > (sorry > > > for the awful plural) linked to those panels. > > > > > > Doing it this way, when I output the DQL, I see: IN (?,?,?,?), but > > then > > > have an error: > > > > > > > > > Invalid parameter number: number of bound variables does not > match > > > number of tokens > > > > > > If I change the double array into just one array, then the DQL only > > > reads: IN ? and I get the same error since I have 4 parameters but > > only > > > 1 question mark. > > > > > > I also tried creating another doctrine query on panels: > > > $panQuery = Doctrine_Query::create()-> > > > select('pa.furniture_id')-> > > > from('Panel pa')-> > > > whereIn('pa.id <http://pa.id> <http://pa.id>', > > array(1,7,8,9)); > > > > > > and having my global query like this: > > > $q =Doctrine_Query::create() > > > ->from('Furniture f') > > > ->where('f.id <http://f.id> <http://f.id> IN (?) ', > > $panQuery->getDql()); > > > > > > The output Dql is something I can get, put in my phpMyAdmin and I > will > > > get 2 results. I get 0 through doctrine though. > > > > > > Any advice on how to use IN within subqueries is very much welcome! > > > > > > -- > > > If you want to report a vulnerability issue on symfony, please send > it > > > to security at symfony-project.com <http://symfony-project.com> > > > > > > You received this message because you are subscribed to the Google > > > Groups "symfony users" group. > > > To post to this group, send email to > > symfony-users@googlegroups.com <mailto: > symfony-users@googlegroups.com> > > > To unsubscribe from this group, send email to > > > > > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > > > > <mailto:symfony-users%2bunsubscr...@googlegroups.com<symfony-users%252bunsubscr...@googlegroups.com> > > > > > For more options, visit this group at > > > http://groups.google.com/group/symfony-users?hl=en > > > > -- > > If you want to report a vulnerability issue on symfony, please send > > it to security at symfony-project.com <http://symfony-project.com> > > > > You received this message because you are subscribed to the Google > > Groups "symfony users" group. > > To post to this group, send email to symfony-users@googlegroups.com > > <mailto:symfony-users@googlegroups.com> > > To unsubscribe from this group, send email to > > > > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > > > > <mailto:symfony-users%2bunsubscr...@googlegroups.com<symfony-users%252bunsubscr...@googlegroups.com> > > > > For more options, visit this group at > > http://groups.google.com/group/symfony-users?hl=en > > > > > > -- > > If you want to report a vulnerability issue on symfony, please send it > > to security at symfony-project.com > > > > You received this message because you are subscribed to the Google > > Groups "symfony users" group. > > To post to this group, send email to symfony-users@googlegroups.com > > To unsubscribe from this group, send email to > > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > > http://groups.google.com/group/symfony-users?hl=en > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en