isNull example

/** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'plugin') {
            $repository = $this->getContainer()->get(ModelManager::class)->getRepository(Plugin::class);
            $queryBuilder = $repository->createQueryBuilder('plugin');
            $result = $queryBuilder->andWhere($queryBuilder->expr()->eq('plugin.capabilityEnable', 'true'))
                ->andWhere($queryBuilder->expr()->neq('plugin.active', 'true'))
                ->andWhere($queryBuilder->expr()->isNull('plugin.installed'))
                ->andWhere($queryBuilder->expr()->neq('plugin.source', ':source'))
                ->setParameter('source', 'Default')
                ->select(['plugin.name'])
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'name');
        }

        return [];
    }

    

  public function condition($field$value = NULL, $operator = '=') {
    $this->condition->condition($field$value$operator);
    return $this;
  }

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

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

  
self::TRANSLATION,
            $query->expr()->andX(
                $query->expr()->eq(self::TRANSLATION . '.articleID', self::PRODUCT . '.id'),
                $query->expr()->eq(self::TRANSLATION . '.languageID', $context->getShop()->getId()),
                $query->expr()->isNotNull(self::TRANSLATION_NAME),
                $query->expr()->neq(self::TRANSLATION_NAME, $query->expr()->literal(''))
            )
        );

        $query->addOrderBy(
            self::exprIf(
                $query->expr()->isNull(self::TRANSLATION_NAME),
                self::PRODUCT . '.name',
                self::TRANSLATION_NAME
            ),
            $sorting->getDirection()
        );
    }
}


  /** * Updates the 'help_search_unindexed_count' state variable. * * The state variable is a count of help topics that have never been indexed. */
  public function updateIndexState() {
    $query = $this->database->select('help_search_items', 'hsi');
    $query->addExpression('COUNT(DISTINCT(hsi.sid))');
    $query->leftJoin('search_dataset', 'sd', 'hsi.sid = sd.sid AND sd.type = :type', [':type' => $this->getType()]);
    $query->isNull('sd.sid');
    $never_indexed = $query->execute()->fetchField();
    $this->state->set('help_search_unindexed_count', $never_indexed);
  }

  /** * {@inheritdoc} */
  public function markForReindex() {
    $this->updateTopicList();
    $this->searchIndex->markForReindex($this->getType());
  }

  
public function unreadTopics($term$uid) {
    $query = $this->connection->select('node_field_data', 'n');
    $query->join('forum', 'f', '[n].[vid] = [f].[vid] AND [f].[tid] = :tid', [':tid' => $term]);
    $query->leftJoin('history', 'h', '[n].[nid] = [h].[nid] AND [h].[uid] = :uid', [':uid' => $uid]);
    $query->addExpression('COUNT([n].[nid])', 'count');
    return $query
      ->condition('status', 1)
      // @todo This should be actually filtering on the desired node status       // field language and just fall back to the default language.       ->condition('n.default_langcode', 1)
      ->condition('n.created', HISTORY_READ_LIMIT, '>')
      ->isNull('h.nid')
      ->addTag('node_access')
      ->execute()
      ->fetchField();
  }

  /** * {@inheritdoc} */
  public function __sleep() {
    $vars = $this->defaultSleep();
    // Do not serialize static cache.

  protected function hasNullFieldPropertyData($table_name$column_name) {
    $query = $this->database->select($table_name, 't')
      ->fields('t', [$column_name])
      ->range(0, 1);
    $query->isNull('t.' . $column_name);
    $result = $query->execute()->fetchAssoc();
    return (bool) $result;
  }

  /** * Gets the schema for a single field definition. * * Entity types may override this method in order to optimize the generated * schema for given field. While all optimizations that apply to a single * field have to be added here, all cross-field optimizations should be via * SqlContentEntityStorageSchema::getEntitySchema() instead; e.g., * an index spanning multiple fields. * * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition * The storage definition of the field whose schema has to be returned. * @param string $table_name * The name of the table columns will be added to. * @param string[] $column_mapping * A mapping of field column names to database column names. * * @return array * The schema definition for the table with the following keys: * - fields: The schema definition for the each field columns. * - indexes: The schema definition for the indexes. * - unique keys: The schema definition for the unique keys. * - foreign keys: The schema definition for the foreign keys. * * @throws \Drupal\Core\Field\FieldException * Exception thrown if the schema contains reserved column names or if the * initial values definition is invalid. */

  protected function queryOpBoolean($field$query_operator = self::EQUAL) {
    if (empty($this->value)) {
      if ($this->accept_null) {
        if ($query_operator === self::EQUAL) {
          $condition = ($this->query->getConnection()->condition('OR'))
            ->condition($field, 0, $query_operator)
            ->isNull($field);
        }
        else {
          $condition = ($this->query->getConnection()->condition('AND'))
            ->condition($field, 0, $query_operator)
            ->isNotNull($field);
        }
        $this->query->addWhere($this->options['group']$condition);
      }
      else {
        $this->query->addWhere($this->options['group']$field, 0, $query_operator);
      }
    }
->andWhere(
                    $builder->expr()->orX(
                        $builder->expr()->eq('sites.grouping', ':g1'),   // = bottom                         $builder->expr()->like('sites.grouping', ':g2'), // like 'bottom|%                         $builder->expr()->like('sites.grouping', ':g3'), // like '|bottom                         $builder->expr()->like('sites.grouping', ':g4')  // like '|bottom|                     )
                )
                ->andWhere(
                    $builder->expr()->orX(
                        $builder->expr()->like('sites.shop_ids', ':shopId'),
                        $builder->expr()->isNull('sites.shop_ids')
                    )
                )
                ->setParameter('g1', $key)
                ->setParameter('g2', $key . '|%')
                ->setParameter('g3', '%|' . $key)
                ->setParameter('g4', '%|' . $key . '|%')
                ->setParameter('shopId', '%|' . $shopId . '|%')
                ->execute()
                ->fetchAll(PDO::FETCH_ASSOC);

            foreach ($current as $item) {
                
unset($conditions[$field]);
        }
      }
      $query->condition('s.lid', $subquery, 'IN');
    }

    // Add conditions for both tables.     foreach ($conditions as $field => $value) {
      $table_alias = $this->dbFieldTable($field);
      $field_alias = $table_alias . '.' . $field;
      if (is_null($value)) {
        $query->isNull($field_alias);
      }
      elseif ($table_alias == 't' && $join === 'leftJoin') {
        // Conditions for target fields when doing an outer join only make         // sense if we add also OR field IS NULL.         $query->condition(($this->connection->condition('OR'))
          ->condition($field_alias(array) $value, 'IN')
          ->isNull($field_alias)
        );
      }
      else {
        $query->condition($field_alias(array) $value, 'IN');
      }
    // EntityQuery. This way we ensure that the database driver is free to     // create its own comparable SQL statement.     $connection = Database::getConnection();
    $expected = $connection->select("entity_test_mulrev", "base_table");
    $expected->addField("base_table", "revision_id", "revision_id");
    $expected->addField("base_table", "id", "id");
    $expected->join("entity_test_mulrev__$figures", "entity_test_mulrev__$figures", '[entity_test_mulrev__' . $figures . '].[entity_id] = [base_table].[id]');
    $expected->join("entity_test_mulrev__$figures", "entity_test_mulrev__{$figures}_2", '[entity_test_mulrev__' . $figures . '_2].[entity_id] = [base_table].[id]');
    $expected->addJoin("LEFT", "entity_test_mulrev__$figures", "entity_test_mulrev__{$figures}_3", '[entity_test_mulrev__' . $figures . '_3].[entity_id] = [base_table].[id]');
    $expected->condition("entity_test_mulrev__$figures.{$figures}_color", ["blue"], "IN");
    $expected->condition("entity_test_mulrev__{$figures}_2.{$figures}_color", ["red"], "IN");
    $expected->isNull("entity_test_mulrev__{$figures}_3.{$figures}_color");
    $expected->orderBy("base_table.id");

    // Apply table prefixes and quote identifiers for the expected SQL.     $expected_string = $connection->prefixTables((string) $expected);
    $expected_string = $connection->quoteIdentifiers($expected_string);
    // Resolve placeholders in the expected SQL to their values.     $quoted = [];
    foreach ($expected->getArguments() as $key => $value) {
      $quoted[$key] = $connection->quote($value);
    }
    $expected_string = strtr($expected_string$quoted);

    
$this->assertCount(0, $names, 'No records found when comparing to NULL.');
  }

  /** * Tests that we can find a record with a NULL value. */
  public function testIsNullCondition() {
    $this->ensureSampleDataNull();

    $names = $this->connection->select('test_null', 'tn')
      ->fields('tn', ['name'])
      ->isNull('age')
      ->execute()->fetchCol();

    $this->assertCount(1, $names, 'Correct number of records found with NULL age.');
    $this->assertEquals('Fozzie', $names[0], 'Correct record returned for NULL age.');
  }

  /** * Tests that we can find a record without a NULL value. */
  public function testIsNotNullCondition() {
    $this->ensureSampleDataNull();

    


    /** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'plugin') {
            $repository = $this->getContainer()->get(ModelManager::class)->getRepository(Plugin::class);
            $queryBuilder = $repository->createQueryBuilder('plugin');
            $result = $queryBuilder->andWhere($queryBuilder->expr()->eq('plugin.capabilityInstall', 'true'))
                ->andWhere($queryBuilder->expr()->isNull('plugin.installed'))
                ->select(['plugin.name'])
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'name');
        }

        return [];
    }

    /** * {@inheritdoc} */
// When there is revision support, the key field is the revision key.       $this->sqlFields["base_table.$revision_field"] = ['base_table', $revision_field];
      // Now add the value column for fetchAllKeyed(). This is always the       // entity id.       $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field];
    }

    // Add a self-join to the base revision table if we're querying only the     // latest revisions.     if ($this->latestRevision && $revision_field) {
      $this->sqlQuery->leftJoin($base_table, 'base_table_2', "[base_table].[$id_field] = [base_table_2].[$id_field] AND [base_table].[$revision_field] < [base_table_2].[$revision_field]");
      $this->sqlQuery->isNull("base_table_2.$id_field");
    }

    if (is_null($this->accessCheck)) {
      throw new QueryException('Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck().');
    }
    if ($this->accessCheck) {
      $this->sqlQuery->addTag($this->entityTypeId . '_access');
    }
    $this->sqlQuery->addTag('entity_query');
    $this->sqlQuery->addTag('entity_query_' . $this->entityTypeId);

    
->andWhere($builder->expr()->eq('coreShops.id', $builder->createNamedParameter($shopId)))
        ;
    }

    protected function isLayerResponsible(?int $shopId): bool
    {
        $queryBuilder = $this->connection->createQueryBuilder();

        return $queryBuilder->select('1')
                ->from('s_core_shops')
                ->andWhere($queryBuilder->expr()->eq('id', ':id'))
                ->andWhere($queryBuilder->expr()->isNull('main_id'))
                ->andWhere($queryBuilder->expr()->lt('`default`', 1))
                ->setParameter('id', $shopId)
                ->execute()->fetchColumn() !== false
        ;
    }
}

  public function statusMessageNotExistsAfterWait(string $type = NULL, int $timeout = 10000): void {
    $selector = $this->buildJavascriptStatusMessageSelector(NULL, $type);
    $status_message_element = $this->waitForElement('xpath', $selector$timeout);
    if ($type) {
      $failure_message = sprintf('A status message of type "%s" appears on this page, but it should not.', $type);
    }
    else {
      $failure_message = 'A status message appears on this page, but it should not.';
    }
    Assert::assertThat($status_message_element, Assert::isNull()$failure_message);
  }

  /** * Asserts that a status message containing given string exists after wait. * * @param string $message * The partial message to assert. * @param string|null $type * The optional message type: status, error, or warning. * @param int $timeout * Optional timeout in milliseconds, defaults to 10000. */
Home | Imprint | This part of the site doesn't use cookies.