You are here

function i18n_select_check_conditions in Internationalization 7

Check all query conditions have a table alias.

Parameters

$table_alias: Optional table alias for fields without table.

Return value

boolean TRUE if table conditions are ok, FALSE otherwise.

1 call to i18n_select_check_conditions()
i18n_select_check_table in i18n_select/i18n_select.module
Check table exists in query and get alias for it.

File

i18n_select/i18n_select.module, line 226
Multilingual content selection module.

Code

function i18n_select_check_conditions($query, $table_alias = NULL) {
  $conditions =& $query
    ->conditions();
  foreach ($conditions as $index => $condition) {
    if (is_array($condition) && !empty($condition['field'])) {
      if (strpos($condition['field'], '.') === FALSE) {
        if ($table_alias) {

          // Change the condition to include a table alias.
          $conditions[$index]['field'] = $table_alias . '.' . $condition['field'];
        }
        else {

          // We won't risk joining anything here.
          return FALSE;
        }
      }
    }
  }
  return TRUE;
}