Where shall I send the chocolates then haha??? Thanks a lot!
2010/8/27 Georg <[email protected]> > I see. > so if the model looks like this > panel: > columns: > id: > furniture_id: > relations: > furniture: {local: furniture_id, foreign: id, foreignAlias: panels} > > you should be able to do it like this: > $query = new Doctrine_Query(); > $query->select('f.*')->distinct()->from('furniture > f')->leftJoin('f.panels p')->whereIn('p.id', array(1,7,8,9)); > > > Am 27.08.2010 07:50, schrieb Sebastien Armand [Pink]: > > 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 <[email protected] <mailto:[email protected]>> > > > > 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 > > <http://f.id> IN (SELECT > > pa.furniture_id FROM Panel pa WHERE pa.id <http://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> <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> > > > <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 <[email protected] <mailto:[email protected]> > > <mailto:[email protected] <mailto:[email protected]>>> > > > > > > try whereIn('f.id <http://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> <http://f.id> > > > > IN (SELECT pa.furniture_id FROM Panel pa WHERE pa.id > > <http://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> > > <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> > > <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> <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 > > > [email protected] > > <mailto:[email protected]> > > <mailto:[email protected] > > <mailto:[email protected]>> > > > > To unsubscribe from this group, send email to > > > > > > [email protected]<symfony-users%[email protected]> > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > > > > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > >> > > > > 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> <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 > > [email protected] <mailto: > [email protected]> > > > <mailto:[email protected] > > <mailto:[email protected]>> > > > To unsubscribe from this group, send email to > > > > > [email protected]<symfony-users%[email protected]> > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > > > > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > >> > > > 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 > > [email protected] <mailto: > [email protected]> > > > To unsubscribe from this group, send email to > > > > > [email protected]<symfony-users%[email protected]> > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > > > > > 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 [email protected] > > <mailto:[email protected]> > > To unsubscribe from this group, send email to > > > > [email protected]<symfony-users%[email protected]> > > > > <mailto:symfony-users%[email protected]<symfony-users%[email protected]> > > > > 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 [email protected] > > To unsubscribe from this group, send email to > > [email protected]<symfony-users%[email protected]> > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected]<symfony-users%[email protected]> > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
