当前位置: 首页>>代码示例>>PHP>>正文


PHP db_and函数代码示例

本文整理汇总了PHP中db_and函数的典型用法代码示例。如果您正苦于以下问题:PHP db_and函数的具体用法?PHP db_and怎么用?PHP db_and使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_and函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: query

 /**
  * {@inheritdoc}
  */
 public function query($group_by = FALSE)
 {
     $required = FALSE;
     $this->queryParseSearchExpression($this->argument);
     if (!isset($this->searchQuery)) {
         $required = TRUE;
     } else {
         $words = $this->searchQuery->words();
         if (empty($words)) {
             $required = TRUE;
         }
     }
     if ($required) {
         if ($this->operator == 'required') {
             $this->query->addWhere(0, 'FALSE');
         }
     } else {
         $search_index = $this->ensureMyTable();
         $search_condition = db_and();
         // Create a new join to relate the 'search_total' table to our current 'search_index' table.
         $definition = array('table' => 'search_total', 'field' => 'word', 'left_table' => $search_index, 'left_field' => 'word');
         $join = Views::pluginManager('join')->createInstance('standard', $definition);
         $search_total = $this->query->addRelationship('search_total', $join, $search_index);
         // Add the search score field to the query.
         $this->search_score = $this->query->addField('', "{$search_index}.score * {$search_total}.count", 'score', array('function' => 'sum'));
         // Add the conditions set up by the search query to the views query.
         $search_condition->condition("{$search_index}.type", $this->searchType);
         $search_dataset = $this->query->addTable('node_search_dataset');
         $conditions = $this->searchQuery->conditions();
         $condition_conditions =& $conditions->conditions();
         foreach ($condition_conditions as $key => &$condition) {
             // Make sure we just look at real conditions.
             if (is_numeric($key)) {
                 // Replace the conditions with the table alias of views.
                 $this->searchQuery->conditionReplaceString('d.', "{$search_dataset}.", $condition);
             }
         }
         $search_conditions =& $search_condition->conditions();
         $search_conditions = array_merge($search_conditions, $condition_conditions);
         // Add the keyword conditions, as is done in
         // SearchQuery::prepareAndNormalize(), but simplified because we are
         // only concerned with relevance ranking so we do not need to normalize.
         $or = db_or();
         foreach ($words as $word) {
             $or->condition("{$search_index}.word", $word);
         }
         $search_condition->condition($or);
         // Add the GROUP BY and HAVING expressions to the query.
         $this->query->addWhere(0, $search_condition);
         $this->query->addGroupBy("{$search_index}.sid");
         $matches = $this->searchQuery->matches();
         $placeholder = $this->placeholder();
         $this->query->addHavingExpression(0, "COUNT(*) >= {$placeholder}", array($placeholder => $matches));
     }
     // Set to NULL to prevent PDO exception when views object is cached
     // and to clear out memory.
     $this->searchQuery = NULL;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:61,代码来源:Search.php

示例2: query

 /**
  * {@inheritdoc}
  */
 public function query($group_by = FALSE)
 {
     $required = FALSE;
     $this->queryParseSearchExpression($this->argument);
     if (!isset($this->searchQuery)) {
         $required = TRUE;
     } else {
         $words = $this->searchQuery->words();
         if (empty($words)) {
             $required = TRUE;
         }
     }
     if ($required) {
         if ($this->operator == 'required') {
             $this->query->addWhere(0, 'FALSE');
         }
     } else {
         $search_index = $this->ensureMyTable();
         $search_condition = db_and();
         // Create a new join to relate the 'search_total' table to our current 'search_index' table.
         $definition = array('table' => 'search_total', 'field' => 'word', 'left_table' => $search_index, 'left_field' => 'word');
         $join = Views::pluginManager('join')->createInstance('standard', $definition);
         $search_total = $this->query->addRelationship('search_total', $join, $search_index);
         $this->search_score = $this->query->addField('', "SUM({$search_index}.score * {$search_total}.count)", 'score', array('aggregate' => TRUE));
         $search_condition->condition("{$search_index}.type", $this->searchType);
         if (!$this->searchQuery->simple()) {
             $search_dataset = $this->query->addTable('search_dataset');
             $conditions = $this->searchQuery->conditions();
             $condition_conditions =& $conditions->conditions();
             foreach ($condition_conditions as $key => &$condition) {
                 // Make sure we just look at real conditions.
                 if (is_numeric($key)) {
                     // Replace the conditions with the table alias of views.
                     $this->searchQuery->conditionReplaceString('d.', "{$search_dataset}.", $condition);
                 }
             }
             $search_conditions =& $search_condition->conditions();
             $search_conditions = array_merge($search_conditions, $condition_conditions);
         } else {
             // Stores each condition, so and/or on the filter level will still work.
             $or = db_or();
             foreach ($words as $word) {
                 $or->condition("{$search_index}.word", $word);
             }
             $search_condition->condition($or);
         }
         $this->query->addWhere(0, $search_condition);
         $this->query->addGroupBy("{$search_index}.sid");
         $matches = $this->searchQuery->matches();
         $placeholder = $this->placeholder();
         $this->query->addHavingExpression(0, "COUNT(*) >= {$placeholder}", array($placeholder => $matches));
     }
     // Set to NULL to prevent PDO exception when views object is cached
     // and to clear out memory.
     $this->searchQuery = NULL;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:59,代码来源:Search.php

示例3: query

 /**
  * See _node_access_where_sql() for a non-views query based implementation.
  */
 public function query()
 {
     $account = $this->view->getUser();
     if (!$account->hasPermission('administer nodes')) {
         $table = $this->ensureMyTable();
         $grants = db_or();
         foreach (node_access_grants('view', $account) as $realm => $gids) {
             foreach ($gids as $gid) {
                 $grants->condition(db_and()->condition($table . '.gid', $gid)->condition($table . '.realm', $realm));
             }
         }
         $this->query->addWhere('AND', $grants);
         $this->query->addWhere('AND', $table . '.grant_view', 1, '>=');
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:18,代码来源:Access.php

示例4: op_word

 function op_word($fulltext_field)
 {
     $where = $this->operator == 'word' ? db_or() : db_and();
     // Don't filter on empty strings.
     if (empty($this->value[0])) {
         return;
     }
     $value = Unicode::strtolower($this->value[0]);
     $words = preg_split('/ /', $value, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($words as $word) {
         $placeholder = $this->placeholder();
         $where->where("{$fulltext_field} LIKE {$placeholder}", array($placeholder => '% ' . db_like($word) . '%'));
     }
     $this->query->addWhere($this->options['group'], $where);
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:15,代码来源:Fulltext.php

示例5: getQuery

 /**
  * {@inheritdoc}
  */
 public function getQuery()
 {
     $query = parent::getQuery();
     // Add a query for meter_category.
     $field = field_info_field('field_group_node');
     $table_name = _field_sql_storage_tablename($field);
     $request = $this->getRequest();
     $query->leftJoin($table_name, 'gn', "message.mid = gn.entity_id AND gn.entity_type='message'");
     $query->innerJoin('field_data_field_node', 'fn', "message.mid = fn.entity_id AND fn.entity_type='message'");
     $query->innerJoin('node', 'node', "fn.field_node_target_id = node.nid");
     // Show only publish content in active stream.
     $query->condition('node.status', 1);
     if (!empty($request['topics'])) {
         // Join related to Articles tables to get V&V activities with user's
         // topics of interest.
         $query->innerJoin('field_data_c4m_vocab_topic', 'crt', "node.nid = crt.entity_id AND crt.entity_type='node'");
     }
     $query->addField('gn', 'field_group_node_target_id', 'group_node');
     if (!empty($request['group'])) {
         if (empty($request['hide_articles'])) {
             $or = db_or();
             $or->condition('gn.field_group_node_target_id', $request['group'], is_array($request['group']) ? 'IN' : '=');
             if (!empty($request['topics'])) {
                 $and = db_and();
                 $and->isNull('gn.field_group_node_target_id');
                 $and->condition('node.type', 'article');
                 $and->condition('crt.c4m_vocab_topic_tid', $request['topics'], is_array($request['topics']) ? 'IN' : '=');
                 $or->condition($and);
             } else {
                 $or->isNull('gn.field_group_node_target_id');
             }
             $query->condition($or);
         } else {
             $query->condition('gn.field_group_node_target_id', $request['group'], is_array($request['group']) ? 'IN' : '=');
         }
     }
     $query->addTag('activity_stream_entity_field_access');
     return $query;
 }
开发者ID:justinlevi,项目名称:capacity4more,代码行数:42,代码来源:C4mRestfulActivityStreamResource.class.php

示例6: hook_query_xmlsitemap_generate_alter

/**
 * Alter the query selecting data from {xmlsitemap} during sitemap generation.
 *
 * @param $query
 *   A Query object describing the composite parts of a SQL query.
 *
 * @see hook_query_TAG_alter()
 */
function hook_query_xmlsitemap_generate_alter(QueryAlterableInterface $query) {
  $sitemap = $query->getMetaData('sitemap');
  if (!empty($sitemap->context['vocabulary'])) {
    $node_condition = db_and();
    $node_condition->condition('type', 'taxonomy_term');
    $node_condition->condition('subtype', $sitemap->context['vocabulary']);
    $normal_condition = db_and();
    $normal_condition->condition('type', 'taxonomy_term', '<>');
    $condition = db_or();
    $condition->condition($node_condition);
    $condition->condition($normal_condition);
    $query->condition($condition);
  }
}
开发者ID:Jobsity,项目名称:pricetaghqpromotional,代码行数:22,代码来源:xmlsitemap.api.php

示例7: addFilter

 public function addFilter()
 {
     if (empty($this->handler->value)) {
         return;
     }
     $this->handler->ensureMyTable();
     // Shorten some variables:
     $field = $this->getField();
     $options = $this->handler->options;
     $operator = $this->handler->operator;
     $formula = !empty($this->formula);
     $value = $this->handler->value;
     if (empty($options['group'])) {
         $options['group'] = 0;
     }
     // add_condition determines whether a single expression is enough(FALSE) or the
     // conditions should be added via an db_or()/db_and() (TRUE).
     $add_condition = TRUE;
     if ($operator == 'not') {
         $value = NULL;
         $operator = 'IS NULL';
         $add_condition = FALSE;
     } elseif ($operator == 'or' && empty($options['reduce_duplicates'])) {
         if (count($value) > 1) {
             $operator = 'IN';
         } else {
             $value = is_array($value) ? array_pop($value) : $value;
             $operator = '=';
         }
         $add_condition = FALSE;
     }
     if (!$add_condition) {
         if ($formula) {
             $placeholder = $this->placeholder();
             if ($operator == 'IN') {
                 $operator = "{$operator} IN({$placeholder})";
             } else {
                 $operator = "{$operator} {$placeholder}";
             }
             $placeholders = array($placeholder => $value) + $this->placeholders;
             $this->handler->query->addWhereExpression($options['group'], "{$field} {$operator}", $placeholders);
         } else {
             $placeholder = $this->placeholder();
             if (count($this->handler->value) > 1) {
                 $placeholder .= '[]';
                 if ($operator == 'IS NULL') {
                     $this->handler->query->addWhereExpression(0, "{$field} {$operator}");
                 } else {
                     $this->handler->query->addWhereExpression(0, "{$field} {$operator}({$placeholder})", array($placeholder => $value));
                 }
             } else {
                 if ($operator == 'IS NULL') {
                     $this->handler->query->addWhereExpression(0, "{$field} {$operator}");
                 } else {
                     $this->handler->query->addWhereExpression(0, "{$field} {$operator} {$placeholder}", array($placeholder => $value));
                 }
             }
         }
     }
     if ($add_condition) {
         $field = $this->handler->realField;
         $clause = $operator == 'or' ? db_or() : db_and();
         foreach ($this->handler->tableAliases as $value => $alias) {
             $clause->condition("{$alias}.{$field}", $value);
         }
         // implode on either AND or OR.
         $this->handler->query->addWhere($options['group'], $clause);
     }
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:69,代码来源:ManyToOneHelper.php

示例8: run

 /**
  * Implements Drupal_SolrDevel_Queue::run().
  */
 public function run()
 {
     $queued = TRUE;
     $env_id = $this->_adapter->getOption('env_id');
     // Initialize the debug array.
     $this->_debug = array('read_only' => FALSE, 'bundle_excluded' => FALSE, 'in_table' => TRUE, 'processed' => FALSE, 'status_callbacks' => array(), 'status_callbacks_skipped' => array(), 'exclude_hooks' => array());
     // Return FALSE if index is read only.
     if (variable_get('apachesolr_read_only', 0)) {
         $this->_debug['read_only'] = TRUE;
         $queued = FALSE;
     }
     // Get bundles that are allowed to be indexed.
     $bundles = drupal_map_assoc(apachesolr_get_index_bundles($env_id, $this->_entityType));
     // Checks whether the bundle is excluded.
     if (!isset($bundles[$this->_bundle])) {
         $this->_debug['bundle_excluded'] = TRUE;
         $queued = FALSE;
     }
     // Get $last_entity_id and $last_changed.
     extract(apachesolr_get_last_index_position($env_id, $this->_entityType));
     $table = apachesolr_get_indexer_table($this->_entityType);
     // Build the queue query.
     $query = db_select($table, 'aie')->fields('aie')->condition('aie.bundle', $bundles)->condition('entity_id', $this->_entityId)->condition(db_or()->condition('aie.changed', $last_changed, '>')->condition(db_and()->condition('aie.changed', $last_changed, '<=')->condition('aie.entity_id', $last_entity_id, '>')));
     // Entity-specific tables don't need this condition.
     if ($table == 'apachesolr_index_entities') {
         $query->condition('aie.entity_type', $this->_entityType);
     }
     // If no records are returned, the item has been processed.
     if (!($record = $query->execute()->fetch())) {
         $this->_debug['processed'] = TRUE;
         $queued = FALSE;
     }
     // Loads index include, which is where the default status callbacks live.
     module_load_include('inc', 'apachesolr', 'apachesolr.index');
     // Ensure entry is in table. If not, we have a problem.
     $query = db_select($table, 'aie')->fields('aie', array('status'))->condition('aie.entity_type', $this->_entityType)->condition('aie.entity_id', $this->_entityId);
     // Invokes status callback to check whether entity should be excluded. For
     // example, the apachesolr_index_node_status_callback() tests if the node
     // status is 0, meaning it is unpublished.
     if ($record = $query->execute()->fetch()) {
         $status_callbacks = apachesolr_entity_get_callback($this->_entityType, 'status callback');
         if (is_array($status_callbacks)) {
             foreach ($status_callbacks as $status_callback) {
                 if (is_callable($status_callback)) {
                     $callback_value = $status_callback($this->_entityId, $this->_entityType);
                     $record->status = $record->status && $callback_value;
                     $this->_debug['status_callbacks'][$status_callback] = !$callback_value;
                     // FALSE
                 } else {
                     $this->_debug['status_callbacks_skipped'][$status_callback] = TRUE;
                 }
             }
         }
     } else {
         // There is a problem with the queue if the data is not here.
         $this->_debug['in_table'] = FALSE;
         $queued = FALSE;
     }
     // Invoke hook_apachesolr_exclude().
     foreach (module_implements('apachesolr_exclude') as $module) {
         $function = $module . '_apachesolr_exclude';
         $exclude = module_invoke($module, 'apachesolr_exclude', $record->entity_id, $this->_entityType, $record, $env_id);
         if (!empty($exclude)) {
             $this->_debug['exclude_hooks'][$function] = TRUE;
             $queued = FALSE;
         } else {
             $this->_debug['exclude_hooks'][$function] = FALSE;
         }
     }
     // Invoke hook_apachesolr_ENTITY_TYPE_exclude().
     foreach (module_implements('apachesolr_' . $this->_entityType . '_exclude') as $module) {
         $function = $module . '_apachesolr_' . $this->_entityType . '_exclude';
         $exclude = module_invoke($module, 'apachesolr_' . $this->_entityType . '_exclude', $record->entity_id, $record, $env_id);
         if (!empty($exclude)) {
             $this->_debug['exclude_hooks'][$function] = TRUE;
             $queued = FALSE;
         } else {
             $this->_debug['exclude_hooks'][$function] = FALSE;
         }
     }
     return $queued;
 }
开发者ID:johnedelatorre,项目名称:fusion,代码行数:85,代码来源:ApacheSolr.php

示例9: query

 /**
  * {@inheritdoc}
  */
 public function query()
 {
     // Since attachment views don't validate the exposed input, parse the search
     // expression if required.
     if (!$this->parsed) {
         $this->queryParseSearchExpression($this->value);
     }
     $required = FALSE;
     if (!isset($this->searchQuery)) {
         $required = TRUE;
     } else {
         $words = $this->searchQuery->words();
         if (empty($words)) {
             $required = TRUE;
         }
     }
     if ($required) {
         if ($this->operator == 'required') {
             $this->query->addWhere($this->options['group'], 'FALSE');
         }
     } else {
         $search_index = $this->ensureMyTable();
         $search_condition = db_and();
         // Create a new join to relate the 'search_total' table to our current
         // 'search_index' table.
         $definition = array('table' => 'search_total', 'field' => 'word', 'left_table' => $search_index, 'left_field' => 'word');
         $join = Views::pluginManager('join')->createInstance('standard', $definition);
         $search_total = $this->query->addRelationship('search_total', $join, $search_index);
         $this->search_score = $this->query->addField('', "{$search_index}.score * {$search_total}.count", 'score', array('function' => 'sum'));
         $search_condition->condition("{$search_index}.type", $this->searchType);
         $search_dataset = $this->query->addTable('node_search_dataset');
         $conditions = $this->searchQuery->conditions();
         $condition_conditions =& $conditions->conditions();
         foreach ($condition_conditions as $key => &$condition) {
             // Make sure we just look at real conditions.
             if (is_numeric($key)) {
                 // Replace the conditions with the table alias of views.
                 $this->searchQuery->conditionReplaceString('d.', "{$search_dataset}.", $condition);
             }
         }
         $search_conditions =& $search_condition->conditions();
         $search_conditions = array_merge($search_conditions, $condition_conditions);
         $this->query->addWhere($this->options['group'], $search_condition);
         $this->query->addGroupBy("{$search_index}.sid");
         $matches = $this->searchQuery->matches();
         $placeholder = $this->placeholder();
         $this->query->addHavingExpression($this->options['group'], "COUNT(*) >= {$placeholder}", array($placeholder => $matches));
     }
     // Set to NULL to prevent PDO exception when views object is cached.
     $this->searchQuery = NULL;
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:54,代码来源:Search.php

示例10: export_gov_micro_page_cleanup

/**
 * Deletes contents that don't have titles, "Document Moved", "Export.gov Page Not Found" and "The Web site cannot be found".
 * These contents are scrapped from export.gov and should not be indexed in solr search engine,
 * Unless otherwise they are properly rendering searched contents.
 */
function export_gov_micro_page_cleanup()
{
    $query = db_select('node', 'n');
    $query->join('field_data_field_exportrip_origin', 'origin', 'n.nid = origin.entity_id');
    $query->fields('n', array('nid', 'title'))->condition('n.type', 'export_gov_micro_site_page', '=')->condition(db_and()->condition(db_or()->condition('n.status', 0, '=')->condition('n.status', 1, '=')))->condition(db_and()->condition(db_or()->condition('n.title', '', '=')->condition('n.title', ' ', '=')->condition('n.title', NULL, '=')->condition('n.title', 'Export.gov Page Not Found', '=')->condition('n.title', 'Document Moved', '=')->condition('n.title', 'The Web site cannot be found', '=')))->range(0, 100);
    $result = $query->execute();
    $results = $result->fetchAll();
    $w = 0;
    $x = 0;
    $y = 0;
    $z = 0;
    foreach ($results as $record) {
        if ($record->title == '' || $record->title == ' ' || $record->title == NULL) {
            $a[] = $record->nid;
            $x++;
        } elseif ($record->title == 'Export.gov Page Not Found') {
            $b[] = $record->nid;
            $y++;
        } elseif ($record->title == 'Document Moved') {
            $c[] = $record->nid;
            $z++;
        } elseif ($record->title == 'The Web site cannot be found') {
            $d[] = $record->nid;
            $w++;
        }
    }
    drupal_set_message(t('Total # of contents to be deleted: %count', array('%count' => count($results))), 'warning');
    if (!empty($results)) {
        if (count($a) > 0) {
            node_delete_multiple($a);
            drupal_set_message(t('Deleted %count contents that don\'t have titles.', array('%count' => count($a))), 'warning');
        }
        if (count($b) > 0) {
            node_delete_multiple($b);
            drupal_set_message(t('Deleted %count content that says "Export.gov Page Not Found".', array('%count' => count($b))), 'warning');
        }
        if (count($c) > 0) {
            node_delete_multiple($c);
            drupal_set_message(t('Deleted %count content that has "Document Moved".', array('%count' => count($c))), 'warning');
        }
        if (count($d) > 0) {
            node_delete_multiple($d);
            drupal_set_message(t('Deleted %count content that has "The Web site cannot be found".', array('%count' => count($d))), 'warning');
        }
    } else {
        drupal_set_message(t('Contents found in DB for deletion: %count', array('%count' => count($w + $x + $y + $z) - 1)), 'warning');
    }
}
开发者ID:hosttor,项目名称:BusinessUSA-OpenSource,代码行数:53,代码来源:CleanUp.php

示例11: removeGroup

 static function removeGroup($type, $id)
 {
     if (!isValidOrganisationType($type)) {
         drupal_set_message(tt('This (%1$s) is not something you can remove.', t_type($type)), 'error');
         return FALSE;
     }
     if (!self::isOwner($type, $id)) {
         drupal_set_message(t('You are not authorised to perform this action'), 'error');
         return FALSE;
     }
     if (self::hasMembers($type, $id)) {
         drupal_set_message(tt('There are already members in this %1$s. You can still edit the %1$s though.', t_type($type)), 'error');
         return FALSE;
     }
     if ($type == _ORGANISATION_GROUP && db_query("SELECT pid FROM soc_projects WHERE org_id = {$id}")->rowCount()) {
         drupal_set_message(tt('There are already projects for this %1$s. You should delete these first.', t_type($type)), 'error');
         return FALSE;
     }
     if ($type == _INSTITUTE_GROUP && db_query("SELECT pid FROM soc_studentgroups WHERE inst_id = {$id}")->rowCount()) {
         drupal_set_message(tt('There are already student groups for this %1$s. You should delete these first.', t_type($type)), 'error');
         return FALSE;
     }
     try {
         if ($type != _PROJECT_OBJ) {
             $num_deleted2 = db_delete("soc_user_membership")->condition('group_id', $id)->condition('type', $type)->execute();
             if (!$num_deleted2) {
                 drupal_set_message(tt('The group had no members.', $type), 'status');
             }
             $subtype = $type == _ORGANISATION_GROUP ? _MENTOR_TYPE : ($type == _INSTITUTE_GROUP ? _SUPERVISOR_TYPE : _STUDENT_GROUP);
             $code_field = $subtype == _STUDENT_GROUP ? 'studentgroup_id' : 'entity_id';
             $num_deleted3 = db_delete("soc_codes")->condition(db_and()->condition($code_field, $id)->condition(db_or()->condition('type', $subtype)->condition('type', "{$type}_admin")))->execute();
             if (!$num_deleted3) {
                 drupal_set_message(tt('The %1$s had no code attached.', $type), 'status');
             }
         }
     } catch (Exception $e) {
         drupal_set_message(tt(' We could not delete the %1$s', t_type($type)) . (_DEBUG ? $ex->getMessage() : ''), 'error');
         return FALSE;
     }
     try {
         $num_deleted = db_delete(tableName($type))->condition(self::keyField($type), $id)->execute();
         if ($num_deleted) {
             drupal_set_message(tt('The %1$s has been deleted.', $type), 'status');
             return TRUE;
         } else {
             drupal_set_message(tt('The %1$s seems to have been deleted already, refresh your screen to see if this is true.', $type), 'error');
             return 0;
         }
     } catch (Exception $e) {
         drupal_set_message(tt(' We could not delete the %1$s', t_type($type)) . (_DEBUG ? $ex->getMessage() : ''), 'error');
         return FALSE;
     }
 }
开发者ID:edwinraycom,项目名称:vals-soc,代码行数:53,代码来源:Groups.php

示例12: opContainsWord

 protected function opContainsWord($field)
 {
     $where = $this->operator == 'word' ? db_or() : db_and();
     // Don't filter on empty strings.
     if (empty($this->value)) {
         return;
     }
     preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $phrase = FALSE;
         // Strip off phrase quotes
         if ($match[2][0] == '"') {
             $match[2] = substr($match[2], 1, -1);
             $phrase = TRUE;
         }
         $words = trim($match[2], ',?!();:-');
         $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($words as $word) {
             $where->condition($field, '%' . db_like(trim($word, " ,!?")) . '%', 'LIKE');
         }
     }
     if (!$where) {
         return;
     }
     // previously this was a call_user_func_array but that's unnecessary
     // as views will unpack an array that is a single arg.
     $this->query->addWhere($this->options['group'], $where);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:28,代码来源:String.php

示例13: get_claim_by_id_and_vcond

function get_claim_by_id_and_vcond($claim_id, $vcond)
{
    db_set_active(CLAIM_DB);
    if (!db_table_exists(CLAIM_COLL)) {
        db_set_active();
        return array();
    }
    $query = db_select(CLAIM_COLL, 'c');
    $query->join(CLAIM_AUTHOR, 'a', 'c.uid = a.uid');
    //JOIN
    $query->fields('c', array('id', 'cid', 'hd', 'copyright', 'display', 'note', 'created', 'verified', 'openmosaic'))->fields('a', array('real_name', 'email', 'phone', 'address', '4digitid'))->condition(db_and()->condition('id', $claim_id, '=')->condition('verified', $vcond, '='));
    //$query->fields('c', array('cid', 'uid', 'open', 'note', 'created', 'verified')) // SELECT the fields from CLAIM_COLL
    //      ->condition('id', $claim_id, '=');                                        // WHERE id = $claim_id
    $result = $query->execute();
    $num_of_result = $result->rowCount();
    // should be 1 if fetching is successful.
    $record = array();
    // empty array
    if ($num_of_result > 0) {
        $record = $result->fetchAssoc();
    }
    db_set_active();
    return $record;
    // if no record found, an empty array is returned;
}
开发者ID:318io,项目名称:318-io,代码行数:25,代码来源:db.php

示例14: __filterEvents

 private function __filterEvents($filter, $fields = NULL)
 {
     $filteredEventIds = array();
     $numFilter = 0;
     $filteredTags = array();
     $filteredBezirke = array();
     $filteredTags = array();
     if (isset($filter['mustHaveGps'])) {
         $numFilters++;
         $resultEvents = db_query("SELECT EID, ADID\n     FROM {aae_data_adresse} ad\n     JOIN {aae_data_event} e\n     WHERE ad.gps_long != '' AND ad.gps_lat != '' AND ad.ADID = e.ort");
         foreach ($resultEvents->fetchAll() as $event) {
             $filteredEventIds[] = $event->EID;
         }
     }
     // end empty-GPS-jumper
     if (isset($filter['tags'])) {
         $tags = db_select($this->tbl_event_sparte, 'hs')->fields('hs', array('hat_EID'));
         $and = db_and();
         foreach ($filter['tags'] as $tag) {
             $tag = $this->clearContent($tag);
             $filteredTags[$tag] = $tag;
             $and->condition('hat_KID', $tag);
             $numFilters++;
         }
         $filterTags = $tags->condition($and)->execute()->fetchAll();
         foreach ($filterTags as $tag) {
             $filteredEventIds[] = $tag->hat_EID;
         }
     }
     // end Tag-Filter
     if (isset($filter['bezirke'])) {
         foreach ($filter['bezirke'] as $bezirk) {
             $numFilters++;
             $bezirk_id = $this->clearContent($bezirk);
             $filteredBezirke[$bezirkId] = $bezirkId;
             $adressen = db_select($this->tbl_adresse, 'a')->fields('a', array('ADID'))->condition('bezirk', $bezirk_id)->execute()->fetchAll();
             foreach ($adressen as $adresse) {
                 $filterBezirke = db_select($this->tbl_event, 'e')->fields('e', array('EID'))->condition('ort', $adresse->ADID)->execute()->fetchAll();
                 foreach ($filterBezirke as $bezirk) {
                     $filteredEventIds[] = $bezirk->EID;
                 }
             }
         }
     }
     // end Bezirke-Filter
     if (isset($filter['keyword'])) {
         $numFilters++;
         $or = db_or()->condition('name', '%' . $filter['keyword'] . '%', 'LIKE')->condition('kurzbeschreibung', '%' . $filter['keyword'] . '%', 'LIKE');
         $filterKeyword = db_select($this->tbl_event, 'e')->fields('e', array('EID'))->condition($or)->execute()->fetchAll();
         foreach ($filterKeyword as $keyword) {
             $filteredEventIds[] = $keyword->EID;
         }
     }
     // end Keyword-Filter
     if (isset($filter['day'])) {
         // Search for the exact date OR multiple-days-events in between
         $numFilters++;
         $resultDays = db_query('SELECT EID FROM {aae_data_event} WHERE (start_ts <= :start AND ende_ts >= :start AND ende_ts NOT LIKE :zeroLike) OR start_ts LIKE :startLike', array(':start' => $filter['day'], ':startLike' => $filter['day'] . '%', ':zeroLike' => '1000-01-01 00:00:0%'));
         foreach ($resultDays as $day) {
             $filteredEventIds[] = $day->EID;
         }
     }
     // end Day-Filter
     if (isset($filter['AID'])) {
         $numFilters++;
         $resultAkteur = db_select($this->tbl_akteur_events, 'ae')->fields('ae')->condition('AID', $filter['AID'])->execute()->fetchAll();
         foreach ($resultAkteur as $akteur) {
             $filteredEventIds[] = $akteur->EID;
         }
     }
     // end AkteurID-Filter
     if (!empty($filteredEventIds) && $fields == 'complete') {
         $filteredEventChildrenIds = db_select($this->tbl_event, 'e')->fields('e', array('EID'))->condition('parent_EID', $filteredEventIds)->execute();
         foreach ($filteredEventChildrenIds->fetchAll() as $child) {
             $filteredEventIds[] = $child->EID;
         }
     }
     return $this->getDuplicates($filteredEventIds, $numFilters);
 }
开发者ID:JuliAne,项目名称:easteasteast,代码行数:79,代码来源:events.php

示例15: getQueue

 function getQueue($show_system_tasks = FALSE)
 {
     if (!empty($this->_userId) and $this->_userId > 0) {
         /* Instance where the user id is known.  need to see if there is a processID given.
          * This means that the mode in which we're working is user based.. we only care about a user in this case
          */
         $queries = array();
         //query to get the user assigned to this task
         if ($this->_mode != 'admin') {
             $this->_mode = 'user';
         }
         if ($this->_debug) {
             watchdog('maestro', "Entering getQueue - {$this->_mode} mode");
         }
         $this->_userTaskCount = 0;
         $query = db_select('maestro_queue', 'a');
         $query->join('maestro_template_data', 'b', 'a.template_data_id = b.id');
         $query->leftJoin('maestro_production_assignments', 'c', 'a.id = c.task_id');
         $query->join('maestro_process', 'd', 'a.process_id = d.id');
         $query->fields('a', array('id', 'template_data_id', 'process_id', 'is_interactive', 'handler', 'task_data', 'created_date', 'started_date'));
         $query->fields('b', array('task_class_name', 'template_id', 'taskname', 'is_dynamic_taskname', 'dynamic_taskname_variable_id'));
         if ($this->_mode == 'admin') {
             $query->fields('c', array('assign_id', 'assign_type'));
             $query->fields('e', array('name'));
             $query->leftJoin('users', 'e', 'c.assign_id = e.uid');
         }
         $query->addField('d', 'pid', 'parent_process_id');
         $query->fields('d', array('tracking_id', 'flow_name'));
         if ($this->_mode != 'admin') {
             $query->condition('c.assign_id', $this->_userId, '=');
         }
         if ($show_system_tasks == FALSE) {
             $query->condition('a.is_interactive', MaestroInteractiveFlag::IS_INTERACTIVE);
         }
         $query->condition(db_or()->condition('a.archived', 0)->condition('a.archived', NULL));
         $query->condition(db_and()->condition('a.status', 0, '>='));
         $query->condition('c.assign_type', MaestroAssignmentTypes::USER, '=');
         $query->orderBy('a.id', 'DESC');
         $queries[MaestroAssignmentTypes::USER] = $query;
         //query to get the users associated with a role assigned to this task
         $query = db_select('maestro_queue', 'a');
         $query->join('maestro_template_data', 'b', 'a.template_data_id = b.id');
         $query->leftJoin('maestro_production_assignments', 'c', 'a.id = c.task_id');
         $query->join('maestro_process', 'd', 'a.process_id = d.id');
         $query->leftJoin('users_roles', 'f', 'c.assign_id = f.rid');
         $query->fields('a', array('id', 'template_data_id', 'process_id', 'is_interactive', 'handler', 'task_data', 'created_date', 'started_date'));
         $query->fields('b', array('task_class_name', 'template_id', 'taskname', 'is_dynamic_taskname', 'dynamic_taskname_variable_id'));
         if ($this->_mode == 'admin') {
             $query->fields('c', array('assign_id', 'assign_type'));
             $query->fields('g', array('name'));
             $query->leftJoin('users', 'e', 'f.uid = e.uid');
             $query->leftJoin('role', 'g', 'c.assign_id = g.rid');
         }
         $query->addField('d', 'pid', 'parent_process_id');
         $query->fields('d', array('tracking_id', 'flow_name'));
         if ($this->_mode != 'admin') {
             $query->condition('f.uid', $this->_userId, '=');
         }
         if ($show_system_tasks == FALSE) {
             $query->condition('a.is_interactive', MaestroInteractiveFlag::IS_INTERACTIVE);
         }
         $query->condition(db_or()->condition('a.archived', 0)->condition('a.archived', NULL));
         $query->condition(db_and()->condition('a.status', 0, '>='));
         $query->condition('c.assign_type', MaestroAssignmentTypes::ROLE, '=');
         $query->orderBy('a.id', 'DESC');
         $queries[MaestroAssignmentTypes::ROLE] = $query;
         if (module_exists('og')) {
             //query gets all og's assigned to this task, up to the logic to determine whether or not they are assigned
             $query = db_select('maestro_queue', 'a');
             $query->join('maestro_template_data', 'b', 'a.template_data_id = b.id');
             $query->leftJoin('maestro_production_assignments', 'c', 'a.id = c.task_id');
             $query->join('maestro_process', 'd', 'a.process_id = d.id');
             $query->leftJoin('users_roles', 'f', 'c.assign_id = f.rid');
             $query->fields('a', array('id', 'template_data_id', 'process_id', 'is_interactive', 'handler', 'task_data', 'created_date', 'started_date'));
             $query->fields('b', array('task_class_name', 'template_id', 'taskname', 'is_dynamic_taskname', 'dynamic_taskname_variable_id'));
             $query->fields('c', array('assign_id', 'assign_type', 'process_variable'));
             if ($this->_mode == 'admin') {
                 $og_values = MaestroOgCommon::getOgTableValues();
                 $query->leftJoin($og_values['table'], 'g', 'c.assign_id = g.' . $og_values['gid_column']);
                 $query->addField('g', $og_values['title_column'], 'name');
             }
             $query->addField('d', 'pid', 'parent_process_id');
             $query->fields('d', array('tracking_id', 'flow_name'));
             if ($show_system_tasks == FALSE) {
                 $query->condition('a.is_interactive', MaestroInteractiveFlag::IS_INTERACTIVE);
             }
             $query->condition(db_or()->condition('a.archived', 0)->condition('a.archived', NULL));
             $query->condition(db_and()->condition('a.status', 0, '>='));
             $query->condition('c.assign_type', MaestroAssignmentTypes::GROUP, '=');
             $query->orderBy('a.id', 'DESC');
             $queries[MaestroAssignmentTypes::GROUP] = $query;
         }
         foreach ($queries as $assign_type => $query) {
             $userTaskResult = $query->execute();
             $numTaskRows = $query->countQuery()->execute()->fetchField();
             if ($numTaskRows > 0) {
                 // Return a semi-colon delimited list of queue id's for that user.
                 foreach ($userTaskResult as $userTaskRecord) {
                     if ($assign_type == MaestroAssignmentTypes::GROUP && $this->_mode != 'admin') {
                         // Test if group name has been set to use a variable for this task
//.........这里部分代码省略.........
开发者ID:kastowo,项目名称:idbigdata,代码行数:101,代码来源:maestro_engine_version1.class.php


注:本文中的db_and函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。