function notifications_query_sql in Notifications 6.4
Same name and namespace in other branches
- 6 notifications.module \notifications_query_sql()
- 6.2 notifications.module \notifications_query_sql()
- 6.3 notifications.module \notifications_query_sql()
Build the SQL statement from query elements
It will build INSERT + SELECT or SELECT queries from its elements
This is a wrapper around messaging_query_sql() that will handle special 'fields' parameters
Return value
3 calls to notifications_query_sql()
- NotificationsBasicTests::testNotificationsQueryBuilder in tests/
notifications_api.test - Test query builder
- notifications_query_subscriptions in includes/
query.inc - Run query for subscriptions table with field conditions
- Notifications_Queue::queue_event in includes/
notifications_queue.class.inc - Queue events for notifications adding query conditions from plug-ins
File
- includes/
query.inc, line 90 - Notifications query API - Helper functions to build monster queries
Code
function notifications_query_sql($query, $execute = FALSE) {
// Where conditions come from 'where' and 'fields' elements
// Field conditions are OR'd or AND'd and added into the other conditions
$where = !empty($query['where']) ? $query['where'] : array();
$where_args = !empty($query['where args']) ? $query['where args'] : array();
if (!empty($query['fields'])) {
$operator = !empty($query['fields operator']) ? $query['fields operator'] : 'OR';
$where[] = '(' . implode(") {$operator} (", $query['fields']) . ')';
}
if (!empty($query['fields args'])) {
$where_args = array_merge($where_args, $query['fields args']);
}
$query['where'] = $where;
$query['where args'] = $where_args;
return messaging_query_sql($query, $execute);
}