select example


    protected function getCheapestPriceIds($products, Group $customerGroup)
    {
        $ids = [];
        foreach ($products as $product) {
            $ids[] = $product->getId();
        }
        $ids = array_unique($ids);

        $subQuery = $this->connection->createQueryBuilder();

        $subQuery->select('prices.id')
            ->from('s_articles_prices', 'prices');

        /* * joins the product variants for the min purchase calculation. * The cheapest price is defined by prices.price * variant.minpurchase (the real basket price) */
        $subQuery->innerJoin(
            'prices',
            's_articles_details',
            'variant',
            'variant.id = prices.articledetailsID'
        );

class Vocabulary extends DrupalSqlBase {

  /** * {@inheritdoc} */
  public function query() {
    $query = $this->select('vocabulary', 'v')
      ->fields('v', [
        'vid',
        'name',
        'description',
        'help',
        'relations',
        'hierarchy',
        'multiple',
        'required',
        'tags',
        'module',
        
if ($this->getModuleSchemaVersion('system') >= 7000) {
      $this->blockTable = 'block';
      $this->blockRoleTable = 'block_role';
    }
    else {
      $this->blockTable = 'blocks';
      $this->blockRoleTable = 'blocks_roles';
    }
    // Drupal 6 & 7 both use the same name for the user roles table.     $this->userRoleTable = 'role';

    return $this->select($this->blockTable, 'b')->fields('b');
  }

  /** * {@inheritdoc} */
  protected function initializeIterator() {
    $this->defaultTheme = $this->variableGet('theme_default', 'Garland');
    $this->adminTheme = $this->variableGet('admin_theme', NULL);
    return parent::initializeIterator();
  }

  

class MigrateMissingDatabaseSource extends SqlBase {

  /** * {@inheritdoc} */
  public function query(): SelectInterface {
    $field_names = ['id'];
    $query = $this
      ->select('missing_database', 'm')
      ->fields('m', $field_names);
    return $query;
  }

  /** * {@inheritdoc} */
  public function fields(): array {
    $fields = [
      'id' => $this->t('ID'),
    ];

    
public function assertFailedLogin(User $account, string $flood_trigger = NULL): void {
    $database = \Drupal::database();
    $edit = [
      'name' => $account->getAccountName(),
      'pass' => $account->passRaw,
    ];
    $this->drupalGet('user/login');
    $this->submitForm($edit, 'Log in');
    if (isset($flood_trigger)) {
      $this->assertSession()->statusCodeEquals(403);
      $this->assertSession()->fieldNotExists('pass');
      $last_log = $database->select('watchdog', 'w')
        ->fields('w', ['message'])
        ->condition('type', 'user')
        ->orderBy('wid', 'DESC')
        ->range(0, 1)
        ->execute()
        ->fetchField();
      if ($flood_trigger == 'user') {
        $this->assertSession()->pageTextMatches("/There (has|have) been more than \w+ failed login attempt.* for this account. It is temporarily blocked. Try again later or request a new password./");
        $this->assertSession()->elementExists('css', 'body.maintenance-page');
        $this->assertSession()->linkExists("request a new password");
        $this->assertSession()->linkByHrefExists(Url::fromRoute('user.pass')->toString());
        


namespace Shopware\Bundle\AttributeBundle\Repository\Reader;

use Shopware\Models\Customer\Customer;

class CustomerReader extends GenericReader
{
    protected function createListQuery()
    {
        $query = $this->entityManager->createQueryBuilder();
        $query->select([
            'entity.id',
            'entity.number',
            'entity.email',
            'entity.active',
            'entity.title',
            'entity.salutation',
            'entity.firstname',
            'entity.lastname',
            'entity.lastLogin',
            'entity.firstLogin',
            'entity.newsletter',
            
$order = $this->Request()->getParam('sort', []);
        if (!empty($order)) {
            $order = array_pop($order);
        }

        $filters = [];
        foreach ($filterParams as $singleFilter) {
            $filters[$singleFilter['property']] = $singleFilter['value'];
        }

        $secondStmt = $this->database
            ->select()
            ->from(['s1' => 's_core_snippets']);

        $secondStmt->joinLeft(
            ['s2' => 's_core_snippets'],
            "s1.namespace = s2.namespace AND s1.name = s2.name AND s2.localeId = $localeId AND s2.shopId = $shopId"
        );

        $secondStmt->reset('columns');
        $secondStmt->columns([
            's2.id',
            's1.namespace',
            

class Book extends DrupalSqlBase {

  /** * {@inheritdoc} */
  public function query() {
    $query = $this->select('book', 'b')->fields('b', ['nid', 'bid']);
    $query->join('menu_links', 'ml', '[b].[mlid] = [ml].[mlid]');
    $ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth'];
    foreach (range(1, 9) as $i) {
      $field = "p$i";
      $ml_fields[] = $field;
      $query->orderBy('ml.' . $field);
    }
    return $query->fields('ml', $ml_fields);
  }

  /** * {@inheritdoc} */
'data' => $this->t('Replies'), 'field' => 'f.comment_count'],
      ['data' => $this->t('Last reply'), 'field' => 'f.last_comment_timestamp'],
    ];

    $order = $this->getTopicOrder($sortby);
    for ($i = 0; $i < count($header)$i++) {
      if ($header[$i]['field'] == $order['field']) {
        $header[$i]['sort'] = $order['sort'];
      }
    }

    $query = $this->connection->select('forum_index', 'f')
      ->extend(PagerSelectExtender::class)
      ->extend(TableSortExtender::class);
    $query->fields('f');
    $query
      ->condition('f.tid', $tid)
      ->addTag('node_access')
      ->addMetaData('base_table', 'forum_index')
      ->orderBy('f.sticky', 'DESC')
      ->orderByHeader($header)
      ->limit($forum_per_page);

    
$filtered = array_filter($chain);

        return $filtered;
    }

    private function getParentLanguageId(?string $languageId): ?string
    {
        if ($languageId === null || !Uuid::isValid($languageId)) {
            throw RoutingException::languageNotFound($languageId);
        }
        $data = $this->connection->createQueryBuilder()
            ->select(['LOWER(HEX(language.parent_id))'])
            ->from('language')
            ->where('language.id = :id')
            ->setParameter('id', Uuid::fromHexToBytes($languageId))
            ->executeQuery()
            ->fetchFirstColumn();

        if (empty($data)) {
            throw RoutingException::languageNotFound($languageId);
        }

        return $data[0];
    }
    // initial error itself. Using Database::closeConnection() we simulate such     // a corrupted connection. In this case dblog has to establish a different     // connection by itself to be able to write the log entry.     Database::closeConnection();

    // Create a log entry.     $this->container->get('logger.factory')->get('php')->error('testConnectionFailureLogging');

    // Re-establish the default database connection.     $database = Database::getConnection();

    $query = $database->select('watchdog')
      ->condition('message', 'testConnectionFailureLogging');
    $query->addExpression('MAX([wid])');
    $wid = $query->execute()->fetchField();
    $this->assertNotEmpty($wid, 'Watchdog entry has been stored in database.');
  }

}

    public function getArticleBaseDataQueryBuilder($articleId)
    {
        /** @var QueryBuilder $builder */
        $builder = $this->getEntityManager()->createQueryBuilder();
        $builder->select(['article', 'mainDetail', 'tax', 'attribute']);
        $builder->from(Product::class, 'article')
                ->leftJoin('article.mainDetail', 'mainDetail')
                ->leftJoin('article.tax', 'tax')
                ->leftJoin('mainDetail.attribute', 'attribute')
                ->where('article.id = :articleId')
                ->setParameter('articleId', $articleId);

        return $builder;
    }

    /** * Used for the article backend module to load the article data into * the module. This function selects only some fragments for the whole article * data. The full article data stack is defined in the * Shopware_Controller_Backend_Article::getArticle function * * @param int $articleId * * @return Query<Product> */

    public function deleteByDate(?DateTimeInterface $since, ?DateTimeInterface $until)
    {
        return $this->getDeleteByDateQueryBuilder($since$until)->getQuery()->execute();
    }

    public function getFindByDateQueryBuilder(?DateTimeInterface $since, ?DateTimeInterface $until): QueryBuilder
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        $qb->select('log')
            ->from(Log::class, 'log');
        $this->addDateConstraint($qb$since$until);

        return $qb;
    }

    public function getDeleteByDateQueryBuilder(?DateTimeInterface $since, ?DateTimeInterface $until): QueryBuilder
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        $qb->delete(Log::class, 'log');
        

class FilterFormat extends DrupalSqlBase {

  /** * {@inheritdoc} */
  public function query() {
    return $this->select('filter_format', 'f')->fields('f');
  }

  /** * {@inheritdoc} */
  public function fields() {
    return [
      'format' => $this->t('Format ID.'),
      'name' => $this->t('The name of the format.'),
      'cache' => $this->t('Whether the format is cacheable.'),
      'status' => $this->t('The status of the format'),
      
// Create user.     $admin_user = $this->drupalCreateUser(['ban IP addresses']);
    $this->drupalLogin($admin_user);
    $this->drupalGet('admin/config/people/ban');
    $connection = Database::getConnection();

    // Ban a valid IP address.     $edit = [];
    $edit['ip'] = '1.2.3.3';
    $this->drupalGet('admin/config/people/ban');
    $this->submitForm($edit, 'Add');
    $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $edit['ip'])->execute()->fetchField();
    $this->assertNotEmpty($ip, 'IP address found in database.');
    $this->assertSession()->pageTextContains('The IP address 1.2.3.3 has been banned.');

    // Try to block an IP address that's already blocked.     $edit = [];
    $edit['ip'] = '1.2.3.3';
    $this->drupalGet('admin/config/people/ban');
    $this->submitForm($edit, 'Add');
    $this->assertSession()->pageTextContains('This IP address is already banned.');

    // Try to block a reserved IP address.
Home | Imprint | This part of the site doesn't use cookies.