Try

$rows = $db->fetchAll( $sql, implode(', ', $id ));

Kevin

> -----Original Message-----
> From: cayley [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 03, 2008 2:41 PM
> To: [email protected]
> Subject: [fw-general] Passing array of values to db statement
> 
> 
> I'm trying to do queries that match results on a lists of values. Ideally
> I
> would like to do something like this:
> 
> 
> $id = array( 1, 2, 3, 6, 10 );
> 
> $sql = "select name from resource where id in ( ? )";
> 
> $rows = $db->fetchAll( $sql, $id );
> 
> 
> and have that return the names of the rows who's ids are 1, 2, 3, 6, 10.
> When I try anything like this using Zend DB I get a "Invalid parameter
> number: number of bound variables does not match number of tokens" error.
> 
> Is there a way to do this built into the db stuff or will I have to expand
> these arrays every time I want to use them in a statement like this?
> 
> Thanks
> --
> View this message in context: http://www.nabble.com/Passing-array-of-
> values-to-db-statement-tp15813319s16154p15813319.html
> Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to