Use this:
->where('column' , array(1,2...n) )
Sent from my iPhone
On 27/08/2010, at 00:05, "Sebastien Armand [Pink]" <[email protected]>
wrote:
It wouldn't be whereIn('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',
$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]>
try whereIn('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
>
> IN (SELECT pa.furniture_id FROM Panel pa WHERE 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>', 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> 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
>
> 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
--
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
--
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
--
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