[development] D7 Query placeholders and values
saschagros at gmail.com
Wed Aug 26 18:18:02 UTC 2009
On Wed, Aug 26, 2009 at 8:11 PM, Nancy Wichmann<nan_wich at bellsouth.net> wrote:
> Since I see Larry Garfield has looked at this list today, I thought I would
> ask this now since I just had this come up.
> I know about the new ":label" for substitution in D7 and have no problem
> with that. But what do I do with an array of values, as in:
> $types = variable_get('my_types_list', array());
> $args += $types;
> $result = db_query(..., $args);
> Yes, I properly used db_placeholders to set the "%s" values in place. The
> query works fine in D6, it's just that I am already looking at teh upgrade
> and wondered about how to do arrays of values like this, when I can't go in
> and add a label to them.
You can use a single placeholder and an array of values and it will just work...
'... WHERE your_field IN (:values)', array(':values' => $array_of_values)
More information about the development