How to dynamically populate the condition method argument in a Dynamic Query I am writing a query that will retrieve nodes that match a set of criteria. Though the number of cirteria is unknown. I was hopping i could pass to the condition() method an array of criteria with a key as the 'column name' and that value as the 'value to match' for that colum. For instance : 

$criteria = array ('nid' =&gt; 1, 'etid' =&gt; '1')

$query = db_select('table', 't');

$query
  -&gt;condition( $criteria)
  -&gt;fields('t', some_field);


I have almost 10 criteria and no way to know which will be selected so writing a query for each wont be possible.

Is there a way to achieve that ? 

EDIT:

i thought about using that :

if (empty($criteria1)){
    $criteria = array (":criteria1"= '*');
}else {
 $criteria = array (":criteria1"=$criteria1);
}
$query = db_query('SELECT nid FROM { parce_index } WHERE criteria1 = :criteria1 AND criteria2= criteria2...',$criteria));


Would that make sense ?
If anyone ever need that i got an answer there. 

http://drupal.org/node/12843

This is useful as well : 

https://stackoverflow.com/questions/7476611/how-to-write-a-query-with-a-dynamic-where-clause