fetchAll example


            ->where(sprintf('article.id IN (%s)', $this->prepareSubQuery()->getSQL()))
            ->groupBy('details.ordernumber')
            ->orderBy('details.ordernumber', 'ASC')
            ->setParameter(':shop', $context->getShopId());

        if ($limit !== null && $offset !== null) {
            $qb->setFirstResult($offset)
                ->setMaxResults($limit);
        }

        $resultArray = $qb->execute()->fetchAll();

        if (!\count($resultArray)) {
            return [];
        }

        $variantUrls = $this->router->generateList(
            array_map(
                function D$variant) {
                    $urlElements = ['controller' => 'detail', 'action' => 'index', 'sArticle' => $variant['articleID'], 'template' => 'ajax'];

                    return $urlElements;
                },
->leftJoin('media', 's_media_album_settings', 'mediaSettings', 'mediaSettings.albumID = media.albumID')
            ->leftJoin('propertyOption', 's_filter_values_attributes', 'propertyOptionAttribute', 'propertyOptionAttribute.valueID = propertyOption.id')
            ->where('filterArticles.articleID IN (:ids)')
            ->addOrderBy('filterArticles.articleID')
            ->addOrderBy('propertyOption.value')
            ->addOrderBy('propertyOption.id')
            ->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY);

        $this->fieldHelper->addPropertyOptionTranslation($query$context);
        $this->fieldHelper->addMediaTranslation($query$context);

        $data = $query->execute()->fetchAll(PDO::FETCH_GROUP);
        $properties = [];

        $hydrator = $this->propertyHydrator;
        foreach ($data as $productId => $values) {
            $options = array_map(static function D$row) use ($hydrator) {
                return $hydrator->hydrateOption($row);
            }$values);
            $properties[$productId] = $options;
        }

        return $properties;
    }
/** * @return int[] */
    private function getProductCategories(int $productId): array
    {
        return $this->connection->createQueryBuilder()
            ->select('categoryID')
            ->from('s_articles_categories', 'category')
            ->where('articleID = :productId')
            ->setParameter(':productId', $productId)
            ->execute()
            ->fetchAll(PDO::FETCH_COLUMN);
    }
}


        if ($limit !== null) {
            $sql = Shopware()->Db()->limit($sql(int) $limit);
        }

        $articles = Shopware()->Db()->fetchAll($sql[
            'orderTime' => $orderTime->format('Y-m-d 00:00:00'),
        ]);

        $prepared = Shopware()->Db()->prepare(
            'INSERT IGNORE INTO s_articles_top_seller_ro (article_id, last_cleared, sales) VALUES (:article_id, :last_cleared, :sales)'
        );

        foreach ($articles as $article) {
            $prepared->execute($article);
        }
    }
->addSelect($this->fieldHelper->getPriceGroupDiscountFields())
            ->addSelect($this->fieldHelper->getPriceGroupFields());

        $query->from('s_core_pricegroups_discounts', 'priceGroupDiscount')
            ->innerJoin('priceGroupDiscount', 's_core_pricegroups', 'priceGroup', 'priceGroup.id = priceGroupDiscount.groupID')
            ->andWhere('priceGroupDiscount.customergroupID = :customerGroup')
            ->groupBy('priceGroupDiscount.id')
            ->orderBy('priceGroupDiscount.groupID')
            ->addOrderBy('priceGroupDiscount.discountstart')
            ->setParameter(':customerGroup', $customerGroup->getId());

        $data = $query->execute()->fetchAll(PDO::FETCH_GROUP);

        $priceGroups = [];

        foreach ($data as $row) {
            $priceGroup = $this->priceHydrator->hydratePriceGroup($row);

            foreach ($priceGroup->getDiscounts() as $discount) {
                $discount->setCustomerGroup($customerGroup);
            }

            $priceGroups[$priceGroup->getId()] = $priceGroup;
        }
$recipients[] = mb_strtolower($recipient->getMailAddress());
            }
        }

        $recipients = array_unique(array_filter(array_map('trim', $recipients)));
        if (empty($recipients)) {
            return [];
        }

        $sql = 'SELECT LOWER(mail_address), id FROM s_mail_log_contact WHERE mail_address IN (:addresses)';
        $foundRecipients = $this->connection->executeQuery($sql['addresses' => $recipients])->fetchAll(PDO::FETCH_KEY_PAIR);

        foreach ($recipients as $recipient) {
            if (\array_key_exists($recipient$foundRecipients)) {
                continue;
            }

            $this->connection->insert('s_mail_log_contact', ['mail_address' => $recipient]);
            $foundRecipients[$recipient] = (int) $this->connection->lastInsertId();
        }

        return $foundRecipients;
    }
if (!$statement) {
      $this->throwPDOException();
    }

    $return = $statement->execute($args);
    if (!$return) {
      $this->throwPDOException();
    }

    // Fetch all the data from the reply, in order to release any lock as soon     // as possible.     $this->data = $statement->fetchAll(\PDO::FETCH_ASSOC);
    $this->rowCount = $this->rowCountEnabled ? $statement->rowCount() : NULL;
    // Destroy the statement as soon as possible. See the documentation of     // \Drupal\sqlite\Driver\Database\sqlite\Statement for an explanation.     unset($statement);
    $this->markResultsetIterable($return);

    $this->columnNames = count($this->data) > 0 ? array_keys($this->data[0]) : [];

    if (isset($startEvent) && $this->connection->isEventEnabled(StatementExecutionEndEvent::class)) {
      $this->connection->dispatchEvent(new StatementExecutionEndEvent(
        $startEvent->statementObjectId,
        
try {
            $query = $db->prepare($sql);
            $query->bindParam('field', $field, PDO::PARAM_STR);
            $query->bindParam('direction', $direction, PDO::PARAM_STR);
            $query->bindParam('limit', $limit, PDO::PARAM_INT);
            $query->bindParam('offset', $offset, PDO::PARAM_INT);
            $query->execute();

            $this->View()->assign([
                'success' => true,
                'data' => $query->fetchAll(PDO::FETCH_ASSOC),
                'total' => $db->fetchColumn('SELECT FOUND_ROWS()'),
            ]);
        } catch (DBALException $exception) {
            $this->View()->assign([
                'success' => false,
                'message' => $exception->getMessage(),
            ]);
        }
    }

    /** * Updates an existing recipient, e.g. to change it's group */


    $query = $this->connection->select('test_task', 't');
    $query
      ->fields('t', ['tid', 'pid', 'task', 'priority']);

    $query = $query
      ->extend(TableSortExtender::class)
      ->orderByHeader($header);

    // We need all the results at once to check the sort.     $tasks = $query->execute()->fetchAll();

    return new JsonResponse([
      'tasks' => $tasks,
    ]);
  }

  /** * Runs a tablesort query with a second order_by after and returns the results. * * This function does care about the page GET parameter, as set by the * test HTTP call. * * @return \Symfony\Component\HttpFoundation\JsonResponse */
/** * Tests language_default migration with unset default language variable. */
  public function testMigrationWithUnsetVariable() {
    // Delete the language_default variable.     $this->sourceDatabase->delete('variable')
      ->condition('name', 'language_default')
      ->execute();
    $this->startCollectingMessages();
    $this->executeMigrations(['language', 'default_language']);

    $messages = $this->migration->getIdMap()->getMessages()->fetchAll();
    // Make sure there's no migration exceptions.     $this->assertEmpty($messages);
    // Make sure the default langcode is 'en', as it was the default on D6 & D7.     $this->assertSame('en', $this->config('system.site')->get('default_langcode'));
  }

  /** * Helper method to test the migration. * * @param string $langcode * The langcode of the default language. */

    public function sGetComparisons()
    {
        if (!$this->session->offsetGet('sessionId')) {
            return [];
        }

        // Get all comparisons for this user         $checkForProduct = $this->db->fetchAll(
            'SELECT * FROM s_order_comparisons WHERE sessionID=?',
            [$this->session->offsetGet('sessionId')]
        );

        if (!\count($checkForProduct)) {
            return [];
        }

        foreach ($checkForProduct as $k => $product) {
            $checkForProduct[$k]['articlename'] = stripslashes($product['articlename']);
            $checkForProduct[$k] = $this->articleModule->sGetTranslation($product$product['articleID'], 'article');
            
$this->assertCount(1, $records, 'There is only one record.');
  }

  /** * Confirms that we can fetch all records into an array explicitly. */
  public function testQueryFetchAllColumn() {
    $query = $this->connection->select('test');
    $query->addField('test', 'name');
    $query->orderBy('name');
    $query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);

    $expected_result = ['George', 'John', 'Paul', 'Ringo'];
    $this->assertEquals($expected_result$query_result, 'Returned the correct result.');
  }

  /** * Confirms that we can fetch an entire column of a result set at once. */
  public function testQueryFetchCol() {
    $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] > :age', [':age' => 25]);
    $column = $result->fetchCol();
    
private function getGroupedFilters($filters)
    {
        $sql = " SELECT optionID, GROUP_CONCAT(filterValues.id SEPARATOR '|') as valueIds FROM s_filter_values filterValues WHERE filterValues.id IN (?) GROUP BY filterValues.optionID ";

        $data = $this->connection->fetchAll(
            $sql,
            [$filters],
            [Connection::PARAM_INT_ARRAY]
        );

        $result = [];
        foreach ($data as $value) {
            $optionId = $value['optionID'];
            if (!\is_string($value['valueIds']) || $value['valueIds'] === '') {
                continue;
            }

            
$this->assertResourceResponse(200, $this->getExpectedDocument()$response$this->getExpectedCacheTags()$this->getExpectedCacheContexts(), FALSE, $dynamic_cache === 'MISS' ? 'HIT' : 'UNCACHEABLE');
    // Assert that Dynamic Page Cache did not store a ResourceResponse object,     // which needs serialization after every cache hit. Instead, it should     // contain a flattened response. Otherwise performance suffers.     // @see \Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber::flattenResponse()     $cache_items = $this->container->get('database')
      ->select('cache_dynamic_page_cache', 'cdp')
      ->fields('cdp', ['data'])
      ->condition('cid', '%[route]=jsonapi.%', 'LIKE')
      ->execute()
      ->fetchAll();
    $this->assertLessThanOrEqual(4, count($cache_items));
    $found_cached_200_response = FALSE;
    $other_cached_responses_are_4xx = TRUE;
    foreach ($cache_items as $cache_item) {
      $cached_data = unserialize($cache_item->data);

      // We might be finding cache redirects when querying like this, so ensure       // we only inspect the actual cached response to see if it got flattened.       if (!isset($cached_data['#cache_redirect'])) {
        $cached_response = $cached_data['#response'];
        if ($cached_response->getStatusCode() === 200) {
          
public function testNodeAccessRecords() {
    // Create an article node.     $node1 = $this->drupalCreateNode(['type' => 'article']);
    $this->assertNotEmpty(Node::load($node1->id()), 'Article node created.');

    // Check to see if grants added by node_test_node_access_records made it in.     $connection = Database::getConnection();
    $records = $connection->select('node_access', 'na')
      ->fields('na', ['realm', 'gid'])
      ->condition('nid', $node1->id())
      ->execute()
      ->fetchAll();
    $this->assertCount(1, $records, 'Returned the correct number of rows.');
    $this->assertEquals('test_article_realm', $records[0]->realm, 'Grant with article_realm acquired for node without alteration.');
    $this->assertEquals(1, $records[0]->gid, 'Grant with gid = 1 acquired for node without alteration.');

    // Create an unpromoted "Basic page" node.     $node2 = $this->drupalCreateNode(['type' => 'page', 'promote' => 0]);
    $this->assertNotEmpty(Node::load($node2->id()), 'Unpromoted basic page node created.');

    // Check to see if grants added by node_test_node_access_records made it in.     $records = $connection->select('node_access', 'na')
      ->fields('na', ['realm', 'gid'])
      
Home | Imprint | This part of the site doesn't use cookies.