function _messaging_query_conditions in Messaging 6.3
Same name and namespace in other branches
- 6.4 messaging.module \_messaging_query_conditions()
- 6 messaging.module \_messaging_query_conditions()
- 6.2 messaging.module \_messaging_query_conditions()
Helper function for query builders.
Using schema data get 'field = [placeholder]' and args arrays
File
- ./
messaging.module, line 988
Code
function _messaging_query_conditions($table, $params) {
$schema = drupal_get_schema($table);
$conditions = $args = array();
foreach ($params as $field => $value) {
$type = $schema['fields'][$field]['type'];
// For array values, build IN conditions
if (is_array($value)) {
$conditions[] = $field . ' IN (' . db_placeholders($value, $type) . ')';
$args = array_merge($args, $value);
}
elseif (is_null($value)) {
$condtions[] = $field . ' IS NULL';
}
else {
$conditions[] = $field . ' = ' . db_type_placeholder($type);
$args[] = $value;
}
}
return array(
'conditions' => $conditions,
'args' => $args,
);
}