alwaysFalse example

$cacheability->addCacheContexts(['user']);
        if ($account->isAuthenticated()) {
          $conditions[] = new EntityCondition($owner_field_name$account->id());
          $cacheability->addCacheTags($entity_type->getListCacheTags());
        }
      }
    }

    // If no conditions were added above, then access wasn't granted to any     // subset, so return alwaysFalse().     if (empty($conditions)) {
      return static::alwaysFalse($entity_type);
    }

    // If more than one condition was added above, then access was granted to     // more than one subset, so combine them with an OR.     if (count($conditions) > 1) {
      return new EntityConditionGroup('OR', $conditions);
    }

    // Otherwise return the single condition.     return $conditions[0];
  }

  

  public function notExists(SelectInterface $select) {
    $this->query->notExists($select);
    return $this;
  }

  /** * {@inheritdoc} */
  public function alwaysFalse() {
    $this->query->alwaysFalse();
    return $this;
  }

  /** * {@inheritdoc} */
  public function __toString() {
    return (string) $this->query;
  }

  /** * {@inheritdoc} */
$next = $specifiers[$key + 1];
            }
            else {
              return 0;
            }
          }
          // If this is a numeric specifier we're adding a condition on the           // specific delta. Since we know that this is a single value base           // field no other value than 0 makes sense.           if (is_numeric($next)) {
            if ($next > 0) {
              $this->sqlQuery->alwaysFalse();
            }
            $key++;
            $next = $specifiers[$key + 1];
          }
          // Is this a field column?           $columns = $field_storage->getColumns();
          if (isset($columns[$next]) || in_array($next$table_mapping->getReservedColumns())) {
            // Use it.             $sql_column = $table_mapping->getFieldColumnName($field_storage$next);
            // Do not process it again.             $key++;
          }
$names = $this->connection->select('test', 'test')
      ->fields('test', ['name'])
      ->condition('age', 27)
      ->execute()->fetchCol();

    $this->assertCount(1, $names);
    $this->assertSame($names[0], 'George');

    $names = $this->connection->select('test', 'test')
      ->fields('test', ['name'])
      ->condition('age', 27)
      ->alwaysFalse()
      ->execute()->fetchCol();

    $this->assertCount(0, $names);
  }

  /** * Tests that we can force an extended query to return an empty result. */
  public function testExtenderAlwaysFalseCondition() {
    $names = $this->connection->select('test', 'test')
      ->extend(SelectExtender::class)
      
$conditionContainer->condition($sql_condition);
      }
      else {
        $type = $this->nestedInsideOrCondition || strtoupper($this->conjunction) === 'OR' || $condition['operator'] === 'IS NULL' ? 'LEFT' : 'INNER';
        $field = $tables->addField($condition['field']$type$condition['langcode']);
        // If the field is trying to query on %delta for a single value field         // then the only supported delta is 0. No other value than 0 makes         // sense. \Drupal\Core\Entity\Query\Sql\Tables::addField() returns 0 as         // the field name for single value fields when querying on their %delta.         if ($field === 0) {
          if ($condition['value'] != 0) {
            $conditionContainer->alwaysFalse();
          }
          continue;
        }
        $condition['real_field'] = $field;
        static::translateCondition($condition$sql_query$tables->isFieldCaseSensitive($condition['field']));

        // Add the translated conditions back to the condition container.         if (isset($condition['where']) && isset($condition['where_args'])) {
          $conditionContainer->where($condition['where']$condition['where_args']);
        }
        else {
          
if ($this->database->schema()->fieldExists('taxonomy_term_data', 'language')) {
      $query->addField('td', 'language', 'td_language');
    }
    // Get data when the i18n_mode column exists and it is not the Drupal 7     // value I18N_MODE_NONE or I18N_MODE_LOCALIZE. Otherwise, return no data.     // @see https://git.drupalcode.org/project/i18n/-/blob/7.x-1.x/i18n.module#L26     if ($this->database->schema()->fieldExists('taxonomy_vocabulary', 'i18n_mode')) {
      $query->addField('tv', 'i18n_mode');
      $query->condition('tv.i18n_mode', ['0', '1'], 'NOT IN');
    }
    else {
      $query->alwaysFalse();
    }

    return $query;
  }

  /** * {@inheritdoc} */
  public function prepareRow(Row $row) {
    if (!parent::prepareRow($row)) {
      return FALSE;
    }

  public function notExists(SelectInterface $select) {
    $this->condition->notExists($select);
    return $this;
  }

  /** * {@inheritdoc} */
  public function alwaysFalse() {
    $this->condition->alwaysFalse();
    return $this;
  }

  /** * {@inheritdoc} */
  public function Dconditions() {
    return $this->condition->conditions();
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.