Beispiel #1
0
/**
 * 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', '<>'));
}
 /**
  * Filter the query for list.
  *
  * @param \SelectQuery $query
  *   The query object.
  *
  * @throws BadRequestException
  *
  * @see \RestfulEntityBase::getQueryForList
  */
 protected function queryForListFilter(\SelectQuery $query)
 {
     foreach ($this->parseRequestForListFilter() as $filter) {
         /* @var ResourceFieldDbColumnInterface $filter_field */
         if (!($filter_field = $this->fieldDefinitions->get($filter['public_field']))) {
             continue;
         }
         $column_name = $filter_field->getColumnForQuery();
         if (in_array(strtoupper($filter['operator'][0]), array('IN', 'NOT IN', 'BETWEEN'))) {
             $query->condition($column_name, $filter['value'], $filter['operator'][0]);
             continue;
         }
         $condition = db_condition($filter['conjunction']);
         for ($index = 0; $index < count($filter['value']); $index++) {
             $condition->condition($column_name, $filter['value'][$index], $filter['operator'][$index]);
         }
         $query->condition($condition);
     }
 }
 public function condition($field, $value = null, $operator = null)
 {
     Internal\condition_hook($field, $value, $operator);
     return parent::condition($field, $value, $operator);
 }
 /**
  * Filter the query for list.
  *
  * @param \SelectQuery $query
  *   The query object.
  *
  * @throws \RestfulBadRequestException
  *
  * @see \RestfulEntityBase::getQueryForList
  */
 protected function queryForListFilter(\SelectQuery $query) {
   $public_fields = $this->getPublicFields();
   foreach ($this->parseRequestForListFilter() as $filter) {
     if (in_array(strtoupper($filter['operator'][0]), array('IN', 'BETWEEN'))) {
       $column_name = $this->getPropertyColumnForQuery($public_fields[$filter['public_field']]);
       $query->condition($column_name, $filter['value'], $filter['operator'][0]);
       continue;
     }
     $condition = db_condition($filter['conjunction']);
     for ($index = 0; $index < count($filter['value']); $index++) {
       $column_name = $this->getPropertyColumnForQuery($public_fields[$filter['public_field']]);
       $condition->condition($column_name, $filter['value'][$index], $filter['operator'][$index]);
     }
     $query->condition($condition);
   }
 }
Beispiel #5
0
 /**
  * @param string $field
  * @param string|array $value
  * @param string $operator
  *
  * @return $this
  */
 public function condition($field, $value = null, $operator = null)
 {
     $this->query->condition($field, $value, $operator);
     return $this;
 }
Beispiel #6
0
 public function setCondition($column, $value)
 {
     $this->selectQuery->condition($column, $value);
 }
/**
 * Improve node limit count request.
 * 
 * Called when counting nodes to know if a limit has been reached.
 * 
 * @param int $lid
 *   The node limit id
 * @param SelectQuery $select
 *   The SQL select query
 */
function hook_node_limit_sql($lid, $select)
{
    $limit = submodule_node_limit_load($lid);
    if (empty($limit)) {
        return;
    }
    $select->condition('uid', $limit['submodule']['uid']);
}