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


PHP db_or函数代码示例

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


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

示例1: fetchResults

 /**
  * Implements LinkitSearchPluginInterface::fetchResults().
  */
 public function fetchResults($search_string)
 {
     // If the $search_string is not a string, something is wrong and an empty
     // array is returned.
     $matches = array();
     // Get the EntityFieldQuery instance.
     $this->getQueryInstance();
     $or = db_or();
     $or->condition('n.title', '%' . db_like($search_string) . '%', 'LIKE');
     $or->condition('bcd.name', '%' . db_like($search_string) . '%', 'LIKE');
     $or->condition('b.biblio_secondary_title', '%' . db_like($search_string) . '%', 'LIKE');
     $or->condition('bkd.word', '%' . db_like($search_string) . '%', 'LIKE');
     $this->query->condition($or);
     $this->query->orderBy('b.biblio_year', 'DESC');
     //ORDER BY created
     // Add the search condition to the query object.
     /*$this->query->propertyCondition($this->entity_field_label,
           '%' . db_like($search_string) . '%', 'LIKE')
       ->addTag('linkit_entity_autocomplete')
       ->addTag('linkit_' . $this->plugin['entity_type'] . '_autocomplete');*/
     /*
     $matches[] = array(
         'title' => $this->entity_field_label,
         'description' => '',
         'path' => '',
         'group' => '',
         'addClass' => '',
     );
     return $matches;
     */
     /*    // Add access tag for the query.
         // There is also a runtime access check that uses entity_access().
         $this->query->addTag($this->plugin['entity_type'] . '_access');
     
         // Bundle check.
         if (isset($this->entity_key_bundle) && isset($this->conf['bundles']) ) {
           $bundles = array_filter($this->conf['bundles']);
           if ($bundles) {
             $this->query->propertyCondition($this->entity_key_bundle, $bundles, 'IN');
           }
         }*/
     // Execute the query.
     $result = $this->query->execute()->fetchAllAssoc('nid');
     /*if (!isset($result[$this->plugin['entity_type']])) {
         return array();
       }*/
     $ids = array_keys($result);
     // Load all the entities with all the ids we got.
     $entities = entity_load('node', $ids);
     foreach ($entities as $key => $entity) {
         // Check the access againt the definded entity access callback.
         if (entity_access('view', 'node', $entity) === FALSE) {
             continue;
         }
         $matches[] = array('title' => biblio_remove_brace($this->createLabel($entity)), 'description' => $this->createDescription($entity) . ' <span class="name">' . $result[$key]->name . '</span>  <span class="year">' . $result[$key]->biblio_year . '</span>', 'path' => $this->createPath($entity), 'group' => $this->createGroup($entity), 'addClass' => $this->createRowClass($entity));
     }
     return $matches;
 }
开发者ID:agroknow,项目名称:water,代码行数:61,代码来源:aklinkitplugin.class.php

示例2: entityFieldQueryAlter

 /**
  * Overrides OgSelectionHandler::entityFieldQueryAlter().
  *
  * Add the user's groups along with the rest of the "public" groups.
  */
 public function entityFieldQueryAlter(SelectQueryInterface $query)
 {
     $gids = og_get_entity_groups();
     if (empty($gids['node'])) {
         return;
     }
     $conditions =& $query->conditions();
     // Find the condition for the "field_data_field_privacy_settings" query, and
     // the one for the "node.nid", so we can later db_or() them.
     $public_condition = array();
     foreach ($conditions as $key => $condition) {
         if ($key !== '#conjunction' && is_string($condition['field'])) {
             if (strpos($condition['field'], 'field_data_field_og_subscribe_settings') === 0) {
                 $public_condition = $condition;
                 unset($conditions[$key]);
             }
             if ($condition['field'] === 'node.nid') {
                 unset($conditions[$key]);
             }
         }
     }
     if (!$public_condition) {
         return;
     }
     $or = db_or();
     $or->condition($public_condition['field'], $public_condition['value'], $public_condition['operator']);
     $or->condition('node.nid', $gids['node'], 'IN');
     $query->condition($or);
 }
开发者ID:joshirohit100,项目名称:dcd2,代码行数:34,代码来源:OgEventsSelectionHandler.class.php

示例3: getLatestContent

 /**
  * Get content changed after the deployment date.
  *
  * @return object[]
  *   Object containing an array of NID and node type.
  */
 public function getLatestContent()
 {
     // EECA subsite case where changed column is having entries equal to 0.
     $or = db_or()->condition('n.created', self::DEPLOYMENT_DATE, '>=')->condition('n.changed', self::DEPLOYMENT_DATE, '>=');
     $query = db_select('node', 'n')->fields('n', ['nid', 'type'])->condition($or);
     return $query->execute()->fetchAll();
 }
开发者ID:ec-europa,项目名称:ec-europa-tools,代码行数:13,代码来源:NEXTEUROPA-13008-content-tranlsation-fix.php

示例4: hook_query_rules_autotag_terms_alter

/**
 * Alter the term DB query.
 *
 * @param SelectQuery $query
 *   The query object ot alter.
 */
function hook_query_rules_autotag_terms_alter($query)
{
    // Join the original term query from rules_autotag with our field table to
    // exclude terms that should not be tagged.
    $query->leftJoin('field_data_field_dont_autotag', 'fd', "t.tid = fd.entity_id AND fd.entity_type = 'taxonomy_term'");
    $query->condition(db_or()->condition('fd.field_dont_autotag_value', NULL)->condition('fd.field_dont_autotag_value', '1', '<>'));
}
开发者ID:agroknow,项目名称:agreri,代码行数:13,代码来源:rules_autotag.api.php

示例5: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['customer_type'] = array('#type' => 'radios', '#options' => array('search' => t('Search for an existing customer.'), 'create' => t('Create a new customer account.'), 'none' => t('No customer account required.')), '#required' => TRUE, '#default_value' => 'search', '#ajax' => array('callback' => array($this, 'customerSelect'), 'wrapper' => 'uc-order-customer', 'progress' => array('type' => 'throbber')));
     $form['customer'] = array('#prefix' => '<div id="uc-order-customer">', '#suffix' => '</div>', '#tree' => TRUE);
     // Create form elements needed for customer search.
     // Shown only when the 'Search for an existing customer.' radio is selected.
     if (!$form_state->hasValue('customer_type') || $form_state->getValue('customer_type') == 'search') {
         // Container for customer search fields.
         $form['customer'] += array('#type' => 'fieldset', '#title' => t('Customer search'), '#description' => t('Enter full or partial information in one or more of the following fields, then press the "Search" button. Search results will match all the provided information.'));
         // Customer first name.
         $form['customer']['first_name'] = array('#type' => 'textfield', '#title' => t('First name'), '#size' => 24, '#maxlength' => 32);
         // Customer last name.
         $form['customer']['last_name'] = array('#type' => 'textfield', '#title' => t('Last name'), '#size' => 24, '#maxlength' => 32);
         // Customer e-mail address.
         $form['customer']['email'] = array('#type' => 'textfield', '#title' => t('E-mail'), '#size' => 24, '#maxlength' => 96);
         // Customer username.
         $form['customer']['username'] = array('#type' => 'textfield', '#title' => t('Username'), '#size' => 24, '#maxlength' => 96);
         $form['customer']['search'] = array('#type' => 'button', '#value' => t('Search'), '#limit_validation_errors' => array(), '#submit' => array(), '#ajax' => array('callback' => array($this, 'customerSearch'), 'wrapper' => 'uc-order-customer-results', 'progress' => array('type' => 'throbber')));
         $form['customer']['uid'] = array('#prefix' => '<div id="uc-order-customer-results">', '#suffix' => '</div>');
         // Search for existing customer by e-mail address.
         if ($form_state->getValue('customer')) {
             $query = db_select('users_field_data', 'u')->distinct();
             $query->leftJoin('uc_orders', 'o', 'u.uid = o.uid');
             $query->fields('u', array('uid', 'name', 'mail'))->fields('o', array('billing_first_name', 'billing_last_name'))->condition('u.uid', 0, '>')->condition(db_or()->isNull('o.billing_first_name')->condition('o.billing_first_name', db_like(trim($form_state->getValue(['customer', 'first_name']))) . '%', 'LIKE'))->condition(db_or()->isNull('o.billing_last_name')->condition('o.billing_last_name', db_like(trim($form_state->getValue(['customer', 'last_name']))) . '%', 'LIKE'))->condition(db_or()->condition('o.primary_email', db_like(trim($form_state->getValue(['customer', 'email']))) . '%', 'LIKE')->condition('u.mail', db_like(trim($form_state->getValue(['customer', 'email']))) . '%', 'LIKE'))->condition('u.name', db_like(trim($form_state->getValue(['customer', 'username']))) . '%', 'LIKE')->orderBy('o.created', 'DESC')->range(0, $limit = 11);
             $result = $query->execute();
             $options = array();
             foreach ($result as $user) {
                 $name = '';
                 if (!empty($user->billing_first_name) && !empty($user->billing_last_name)) {
                     $name = $user->billing_first_name . ' ' . $user->billing_last_name . ' ';
                 }
                 // Options formatted as "First Last <email@example.com> (username)".
                 $options[$user->uid] = $name . '&lt;' . $user->mail . '&gt;' . ' (' . $user->name . ')';
             }
             $max = FALSE;
             if (count($options) == $limit) {
                 array_pop($options);
                 $max = TRUE;
             }
             if (!empty($options)) {
                 // Display search results.
                 $form['customer']['uid'] += array('#type' => 'radios', '#title' => t('Select customer'), '#description' => $max ? t('More than @limit results found. Refine your search to find other customers.', ['@limit' => $limit - 1]) : '', '#options' => $options, '#default_value' => key($options));
             } else {
                 // No search results found.
                 $form['customer']['uid'] += array('#markup' => '<p>' . t('Search returned no results.') . '</p>');
             }
         }
     } elseif ($form_state->getValue('customer_type') == 'create') {
         // Container for new customer information.
         $form['customer'] += array('#type' => 'fieldset', '#title' => t('New customer details'));
         // Customer e-mail address.
         $form['customer']['email'] = array('#type' => 'email', '#title' => t('Customer e-mail address'), '#size' => 24, '#maxlength' => 96);
         // Option to notify customer.
         $form['customer']['sendmail'] = array('#type' => 'checkbox', '#title' => t('E-mail account details to customer.'));
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Create order'));
     return $form;
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:62,代码来源:OrderCreateForm.php

示例6: query

 public function query()
 {
     $this->ensureMyTable();
     $subselect = db_select('comment_field_data', 'c');
     $subselect->addField('c', 'cid');
     $subselect->condition('c.uid', $this->value, $this->operator);
     $entity_id = $this->definition['entity_id'];
     $entity_type = $this->definition['entity_type'];
     $subselect->where("c.entity_id = {$this->tableAlias}.{$entity_id}");
     $subselect->condition('c.entity_type', $entity_type);
     $condition = db_or()->condition("{$this->tableAlias}.uid", $this->value, $this->operator)->exists($subselect);
     $this->query->addWhere($this->options['group'], $condition);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:13,代码来源:UserUid.php

示例7: addProjectCondition

 public static function addProjectCondition(&$query, $project_alias = 'p.')
 {
     // we want to deliver all the non-draft projects except for the owner (or colleagues) of these projects
     $myorgs = Organisations::getMyOrganisations();
     if (gettype($query) == 'string') {
         $query .= " AND ({$project_alias}state <> 'draft'" . ($myorgs ? " OR {$project_alias}org_id IN (" . implode($myorgs, ',') . "))" : ")");
     } else {
         if ($myorgs) {
             $query->condition(db_or()->condition("{$project_alias}state", 'draft', '<>')->condition("{$project_alias}org_id", $myorgs, 'IN'));
         } else {
             $query->condition('state', 'draft', '<>');
         }
     }
 }
开发者ID:edwinraycom,项目名称:vals-soc,代码行数:14,代码来源:Project.php

示例8: query

 public function query()
 {
     // If no filter values are present, then do nothing.
     if (count($this->value) == 0) {
         return;
     } elseif (count($this->value) == 1) {
         // Sometimes $this->value is an array with a single element so convert it.
         if (is_array($this->value)) {
             $this->value = current($this->value);
         }
         $operator = '=';
     } else {
         $operator = 'IN';
         # " IN (" . implode(', ', array_fill(0, sizeof($this->value), '%d')) . ")";
     }
     // The normal use of ensureMyTable() here breaks Views.
     // So instead we trick the filter into using the alias of the base table.
     // See http://drupal.org/node/271833
     // If a relationship is set, we must use the alias it provides.
     if (!empty($this->relationship)) {
         $this->tableAlias = $this->relationship;
     } elseif (isset($this->query->table_queue[$this->view->storage->get('base_table')]['alias'])) {
         $this->tableAlias = $this->query->table_queue[$this->view->storage->get('base_table')]['alias'];
     } else {
         return;
     }
     // Now build the subqueries.
     $subquery = db_select('taxonomy_index', 'tn');
     $subquery->addField('tn', 'nid');
     $where = db_or()->condition('tn.tid', $this->value, $operator);
     $last = "tn";
     if ($this->options['depth'] > 0) {
         $subquery->leftJoin('taxonomy_term_hierarchy', 'th', "th.tid = tn.tid");
         $last = "th";
         foreach (range(1, abs($this->options['depth'])) as $count) {
             $subquery->leftJoin('taxonomy_term_hierarchy', "th{$count}", "{$last}.parent = th{$count}.tid");
             $where->condition("th{$count}.tid", $this->value, $operator);
             $last = "th{$count}";
         }
     } elseif ($this->options['depth'] < 0) {
         foreach (range(1, abs($this->options['depth'])) as $count) {
             $subquery->leftJoin('taxonomy_term_hierarchy', "th{$count}", "{$last}.tid = th{$count}.parent");
             $where->condition("th{$count}.tid", $this->value, $operator);
             $last = "th{$count}";
         }
     }
     $subquery->condition($where);
     $this->query->addWhere($this->options['group'], "{$this->tableAlias}.{$this->realField}", $subquery, 'IN');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:49,代码来源:TaxonomyIndexTidDepth.php

示例9: query

 public function query()
 {
     $this->ensureMyTable();
     $field = $this->tableAlias . '.' . $this->realField . ' ';
     $or = db_or();
     if (empty($this->value)) {
         $or->condition($field, '***CURRENT_USER***', '<>');
         if ($this->accept_null) {
             $or->isNull($field);
         }
     } else {
         $or->condition($field, '***CURRENT_USER***', '=');
     }
     $this->query->addWhere($this->options['group'], $or);
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:15,代码来源:Current.php

示例10: 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

示例11: 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

示例12: convert

 /**
  * {@inheritdoc}
  */
 public function convert(TargetInterface $target)
 {
     $indexer = $target->getIndexer('function');
     // @FIXME This is not working (returns empty result set)...don't know why.
     $alter_hooks = $indexer->getQuery()->condition(db_or()->condition('id', $target->id() . '_form_alter')->condition('id', db_like($target->id() . '_form_%_alter'), 'LIKE'))->execute();
     foreach ($alter_hooks as $alter_hook) {
         /** @var \Pharborist\Functions\FunctionDeclarationNode $function */
         $function = $indexer->get($alter_hook->id);
         $parameters = $function->getParameters();
         if (sizeof($parameters) > 1) {
             $parameters[1]->setTypeHint('\\Drupal\\Core\\Form\\FormStateInterface');
             $target->save($function);
         }
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:18,代码来源:HookFormAlter.php

示例13: query

 public function query($group_by = FALSE)
 {
     $this->ensureMyTable();
     // Use the table definition to correctly add this user ID condition.
     if ($this->table != 'comment_field_data') {
         $subselect = $this->database->select('comment_field_data', 'c');
         $subselect->addField('c', 'cid');
         $subselect->condition('c.uid', $this->argument);
         $entity_id = $this->definition['entity_id'];
         $entity_type = $this->definition['entity_type'];
         $subselect->where("c.entity_id = {$this->tableAlias}.{$entity_id}");
         $subselect->condition('c.entity_type', $entity_type);
         $condition = db_or()->condition("{$this->tableAlias}.uid", $this->argument, '=')->exists($subselect);
         $this->query->addWhere(0, $condition);
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:16,代码来源:UserUid.php

示例14: query

 public function query($group_by = FALSE)
 {
     $this->ensureMyTable();
     if (!empty($this->options['break_phrase'])) {
         $tids = new \stdClass();
         $tids->value = $this->argument;
         $tids = $this->breakPhrase($this->argument, $tids);
         if ($tids->value == array(-1)) {
             return FALSE;
         }
         if (count($tids->value) > 1) {
             $operator = 'IN';
         } else {
             $operator = '=';
         }
         $tids = $tids->value;
     } else {
         $operator = "=";
         $tids = $this->argument;
     }
     // Now build the subqueries.
     $subquery = db_select('taxonomy_index', 'tn');
     $subquery->addField('tn', 'nid');
     $where = db_or()->condition('tn.tid', $tids, $operator);
     $last = "tn";
     if ($this->options['depth'] > 0) {
         $subquery->leftJoin('taxonomy_term_hierarchy', 'th', "th.tid = tn.tid");
         $last = "th";
         foreach (range(1, abs($this->options['depth'])) as $count) {
             $subquery->leftJoin('taxonomy_term_hierarchy', "th{$count}", "{$last}.parent = th{$count}.tid");
             $where->condition("th{$count}.tid", $tids, $operator);
             $last = "th{$count}";
         }
     } elseif ($this->options['depth'] < 0) {
         foreach (range(1, abs($this->options['depth'])) as $count) {
             $subquery->leftJoin('taxonomy_term_hierarchy', "th{$count}", "{$last}.tid = th{$count}.parent");
             $where->condition("th{$count}.tid", $tids, $operator);
             $last = "th{$count}";
         }
     }
     $subquery->condition($where);
     $this->query->addWhere(0, "{$this->tableAlias}.{$this->realField}", $subquery, 'IN');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:43,代码来源:IndexTidDepth.php

示例15: entityQueryAlter

 /**
  * {@inheritdoc}
  */
 public function entityQueryAlter(SelectInterface $query)
 {
     if (\Drupal::currentUser()->hasPermission('administer users')) {
         // In addition, if the user is administrator, we need to make sure to
         // match the anonymous user, that doesn't actually have a name in the
         // database.
         $conditions =& $query->conditions();
         foreach ($conditions as $key => $condition) {
             if ($key !== '#conjunction' && is_string($condition['field']) && $condition['field'] === 'users_field_data.name') {
                 // Remove the condition.
                 unset($conditions[$key]);
                 // Re-add the condition and a condition on uid = 0 so that we end up
                 // with a query in the form:
                 // WHERE (name LIKE :name) OR (:anonymous_name LIKE :name AND uid = 0)
                 $or = db_or();
                 $or->condition($condition['field'], $condition['value'], $condition['operator']);
                 // Sadly, the Database layer doesn't allow us to build a condition
                 // in the form ':placeholder = :placeholder2', because the 'field'
                 // part of a condition is always escaped.
                 // As a (cheap) workaround, we separately build a condition with no
                 // field, and concatenate the field and the condition separately.
                 $value_part = db_and();
                 $value_part->condition('anonymous_name', $condition['value'], $condition['operator']);
                 $value_part->compile(Database::getConnection(), $query);
                 $or->condition(db_and()->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => user_format_name(user_load(0))))->condition('base_table.uid', 0));
                 $query->condition($or);
             }
         }
     }
     // Add the filter by role option.
     if (!empty($this->fieldDefinition->getSetting('handler_settings')['filter'])) {
         $filter_settings = $this->fieldDefinition->getSetting('handler_settings')['filter'];
         if ($filter_settings['type'] == 'role') {
             $tables = $query->getTables();
             $base_table = $tables['base_table']['alias'];
             $query->join('users_roles', 'ur', $base_table . '.uid = ur.uid');
             $query->condition('ur.rid', $filter_settings['role']);
         }
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:43,代码来源:UserSelection.php


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