fetchAssoc example

$key = empty($data['templateVar']) ? null : $data['templateVar'];

        /** @var Group $model */
        $model = $repository->findOneBy(['key' => $key]);
        if ($model !== null) {
            $manager->remove($model);
            $manager->flush();
        }

        try {
            // First, get an array containing all sites id and grouping             $sites = Shopware()->Db()->fetchAssoc('SELECT id,grouping FROM s_cms_static');

            // Check is associated with the requested group             // If so, either just delete it or, if the site would become an orphan, move it to the group disabled             foreach ($sites as $site) {
                // Try to explode into an array                 $groups = explode('|', $site['grouping']);

                // If we only have one group, exploding isn't possible, thus we create the array                 (\count($groups) == 1) ? $groups = [$site['grouping']] : null;

                // If the current site is associated with the requested group and has no other groups
// Get the translation, if one exists, for the property not already in the     // row.     $other_property = ($property == 'name') ? 'description' : 'name';
    $query = $this->select('i18n_strings', 'i18n')
      ->fields('i18n', ['lid'])
      ->condition('i18n.type', 'term')
      ->condition('i18n.property', $other_property)
      ->condition('i18n.objectid', $tid);
    $query->leftJoin('locales_target', 'lt', '[i18n].[lid] = [lt].[lid]');
    $query->condition('lt.language', $language);
    $query->addField('lt', 'translation');
    $results = $query->execute()->fetchAssoc();
    if ($results) {
      $row->setSourceProperty($other_property . '_translated', $results['translation']);
    }
    else {
      // The translation does not exist.       $row->setSourceProperty($other_property . '_translated', NULL);
    }

    return parent::prepareRow($row);
  }

  
$plugins = $initializer->initializePlugins();

        foreach ($plugins as $plugin) {
            $pluginInfoPath = $plugin->getPath() . '/plugin.xml';
            if (is_file($pluginInfoPath)) {
                $xmlConfigReader = new XmlPluginReader();
                $info = $xmlConfigReader->read($pluginInfoPath);
            } else {
                $info = [];
            }

            $currentPluginInfo = $this->em->getConnection()->fetchAssoc(
                'SELECT * FROM s_core_plugins WHERE `name` LIKE ?',
                [$plugin->getName()]
            );

            $translations = [];
            $translatableInfoKeys = ['label', 'description'];
            foreach ($info as $key => $value) {
                if (!\in_array($key$translatableInfoKeys, true)) {
                    continue;
                }

                
'location'    => $base_root . \Drupal::request()->getRequestUri(),
      'hostname'    => $base_root,
      'timestamp'   => \Drupal::time()->getRequestTime(),
    ]);
    $insert->execute();

    // Test that the first row exists with the expected value for wid.     $result = $connection->select('watchdog')
      ->fields('watchdog', ['wid'])
      ->condition('wid', 2147483647000)
      ->execute()
      ->fetchAssoc();
    $this->assertNotEmpty($result, 'The row with a big value for wid exists.');

    // Test that the second row exists with the expected value for wid.     $result = $connection->select('watchdog')
      ->fields('watchdog', ['wid'])
      ->condition('wid', 2147483647000 + 1)
      ->execute()
      ->fetchAssoc();
    $this->assertNotEmpty($result, 'The row without a value for wid exists, and has the correct auto-incremented value for wid.');
  }

}

  public function getTranslations(array $conditions = [], array $options = []) {
    return $this->dbStringLoad($conditions['translation' => TRUE] + $options, 'Drupal\locale\TranslationString');
  }

  /** * {@inheritdoc} */
  public function findString(array $conditions) {
    $values = $this->dbStringSelect($conditions)
      ->execute()
      ->fetchAssoc();

    if (!empty($values)) {
      $string = new SourceString($values);
      $string->setStorage($this);
      return $string;
    }
  }

  /** * {@inheritdoc} */
  

        $articles = Shopware()->Db()->fetchAssoc($sql);
        $data = [
            'count' => \count($articles),
            'numbers' => array_keys($articles),
        ];

        if (empty($articles)) {
            return $data;
        }

        $job = $args->getJob();

        


        return Shopware()->Db()->fetchAssoc($sql[$sendTime]);
    }

    /** * @param int[] $orderIds * * @return array */
    public function getCustomers($orderIds)
    {
        $orderIds = Shopware()->Db()->quote($orderIds);
        $sql = " SELECT b.orderID, b.company AS billing_company, b.department AS billing_department, b.salutation AS billing_salutation, u.customernumber, b.firstname AS billing_firstname, b.lastname AS billing_lastname, b.street AS billing_street, b.zipcode AS billing_zipcode, b.city AS billing_city, b.phone AS phone, b.phone AS billing_phone, b.countryID AS billing_countryID, bc.countryname AS billing_country, bc.countryiso AS billing_countryiso, bca.name AS billing_countryarea, bc.countryen AS billing_countryen, b.ustid, ba.text1 AS billing_text1, ba.text2 AS billing_text2, ba.text3 AS billing_text3, ba.text4 AS billing_text4, ba.text5 AS billing_text5, ba.text6 AS billing_text6, b.orderID as orderID, s.company AS shipping_company, s.department AS shipping_department, s.salutation AS shipping_salutation, s.firstname AS shipping_firstname, s.lastname AS shipping_lastname, s.street AS shipping_street, s.zipcode AS shipping_zipcode, s.city AS shipping_city, s.countryID AS shipping_countryID, sc.countryname AS shipping_country, sc.countryiso AS shipping_countryiso, sca.name AS shipping_countryarea, sc.countryen AS shipping_countryen, sa.text1 AS shipping_text1, sa.text2 AS shipping_text2, sa.text3 AS shipping_text3, sa.text4 AS shipping_text4, sa.text5 AS shipping_text5, sa.text6 AS shipping_text6, u.*, g.id AS preisgruppe, g.tax AS billing_net FROM s_order_billingaddress as b LEFT JOIN s_order_shippingaddress as s ON s.orderID = b.orderID LEFT JOIN s_user as u ON b.userID = u.id LEFT JOIN s_user_addresses as ub ON u.default_billing_address_id = ub.id AND u.id = ub.user_id LEFT JOIN s_core_countries as bc ON bc.id = b.countryID LEFT JOIN s_core_countries as sc ON sc.id = s.countryID LEFT JOIN s_core_customergroups as g ON u.customergroup = g.groupkey LEFT JOIN s_core_countries_areas bca ON bc.areaID = bca.id LEFT JOIN s_core_countries_areas sca ON sc.areaID = sca.id LEFT JOIN s_order_billingaddress_attributes ba ON b.id = ba.billingID LEFT JOIN s_order_shippingaddress_attributes sa ON s.id = sa.shippingID WHERE b.orderID IN (

class FieldInstancePerFormDisplay extends DrupalSqlBase {

  /** * {@inheritdoc} */
  protected function initializeIterator() {
    $rows = [];
    $result = $this->prepareQuery()->execute();
    while ($field_row = $result->fetchAssoc()) {
      $bundle = $field_row['type_name'];
      $field_name = $field_row['field_name'];

      $index = "$bundle.$field_name";
      $rows[$index]['type_name'] = $bundle;
      $rows[$index]['widget_active'] = (bool) $field_row['widget_active'];
      $rows[$index]['field_name'] = $field_name;
      $rows[$index]['type'] = $field_row['type'];
      $rows[$index]['module'] = $field_row['module'];
      $rows[$index]['weight'] = $field_row['weight'];
      $rows[$index]['widget_type'] = $field_row['widget_type'];
      

  protected function getUserFromSession(SessionInterface $session) {
    if ($uid = $session->get('uid')) {
      // @todo Load the User entity in SessionHandler so we don't need queries.       // @see https://www.drupal.org/node/2345611       $values = $this->connection
        ->query('SELECT * FROM {users_field_data} [u] WHERE [u].[uid] = :uid AND [u].[default_langcode] = 1', [':uid' => $uid])
        ->fetchAssoc();

      // Check if the user data was found and the user is active.       if (!empty($values) && $values['status'] == 1) {
        // Add the user's roles.         $rids = $this->connection
          ->query('SELECT [roles_target_id] FROM {user__roles} WHERE [entity_id] = :uid', [':uid' => $values['uid']])
          ->fetchCol();
        $values['roles'] = array_merge([AccountInterface::AUTHENTICATED_ROLE]$rids);

        return new UserSession($values);
      }
    }
    return $schema + $custom_settings;
  }

  /** * {@inheritdoc} */
  public function getRowBySource(array $source_id_values) {
    $query = $this->getDatabase()->select($this->mapTableName(), 'map')
      ->fields('map');
    $query->condition($this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
    $result = $query->execute();
    return $result->fetchAssoc();
  }

  /** * {@inheritdoc} */
  public function getRowByDestination(array $destination_id_values) {
    $query = $this->getDatabase()->select($this->mapTableName(), 'map')
      ->fields('map');
    foreach ($this->destinationIdFields() as $field_name => $destination_id) {
      if (!isset($destination_id_values[$field_name])) {
        return [];
      }

class Shopware_Controllers_Backend_CustomSorting extends Shopware_Controllers_Backend_Application
{
    protected $model = CustomSorting::class;

    public function copyCategorySettingsAction()
    {
        $categoryId = (int) $this->Request()->getParam('categoryId');

        $connection = $this->container->get(\Doctrine\DBAL\Connection::class);

        $data = $connection->fetchAssoc(
            'SELECT `hide_sortings`, `sorting_ids` FROM s_categories WHERE id = :id',
            [':id' => $categoryId]
        );

        $connection->executeUpdate(
            'UPDATE s_categories SET `hide_sortings` = :hideSortings, `sorting_ids` = :sortingIds WHERE path LIKE :path',
            [
                ':hideSortings' => (int) $data['hide_sortings'],
                ':sortingIds' => (string) $data['sorting_ids'],
                ':path' => '%|' . $categoryId . '|%',
            ]
        );
foreach ($this->resultObject as $row) {
                $this->resultArray[] = (array) $row;
            }

            return $this->resultArray;
        }

        if ($this->rowData !== null) {
            $this->dataSeek();
        }

        while ($row = $this->fetchAssoc()) {
            $this->resultArray[] = $row;
        }

        return $this->resultArray;
    }

    /** * Returns the results as an array of objects. * * If no results, an empty array is returned. * * @return array<int, stdClass> * @phpstan-return list<stdClass> */
return sqlsrv_fetch_array($this->resultID, SQLSRV_FETCH_ASSOC);
    }

    /** * Returns the result set as an object. * * @return Entity|false|object|stdClass */
    protected function fetchObject(string $className = 'stdClass')
    {
        if (is_subclass_of($className, Entity::class)) {
            return empty($data = $this->fetchAssoc()) ? false : (new $className())->injectRawData($data);
        }

        return sqlsrv_fetch_object($this->resultID, $className);
    }

    /** * Returns the number of rows in the resultID (i.e., SQLSRV query result resource) */
    public function getNumRows(): int
    {
        if (is_int($this->numRows)) {
            
$this->assertSame(15, strlen($data), 'Test data contains a NULL.');
    $id = $this->connection->insert('test_one_blob')
      ->fields(['blob1' => $data])
      ->execute();

    $data .= $data;
    $this->connection->update('test_one_blob')
      ->condition('id', $id)
      ->fields(['blob1' => $data])
      ->execute();

    $r = $this->connection->query('SELECT * FROM {test_one_blob} WHERE [id] = :id', [':id' => $id])->fetchAssoc();
    $this->assertSame($data$r['blob1']new FormattableMarkup('Can update a blob: id @id, @data.', ['@id' => $id, '@data' => serialize($r)]));
  }

  /** * Tests that we can update a blob column to null. */
  public function testUpdateNullBlob() {
    $id = $this->connection->insert('test_one_blob')
      ->fields(['blob1' => 'test'])
      ->execute();
    $r = $this->connection->query('SELECT * FROM {test_one_blob} WHERE [id] = :id', [':id' => $id])->fetchAssoc();
    
$select->where($sectionColumn . '=?', $sectionArray[$key]);
                    }
                }
            } else {
                $select->where($this->_sectionColumn . '=?', $section);
            }
        }

        if ($this->_valueColumn !== '*') {
            $data = $dbTable->getAdapter()->fetchPairs($select);
        } else {
            $data = $dbTable->getAdapter()->fetchAssoc($select);
        }

        if ($this->_automaticSerialization) {
            foreach ($data as $key => $value) {
                $data[$key] = unserialize($value['allowed_classes' => false]);
            }
        }

        return $data;
    }
}
Home | Imprint | This part of the site doesn't use cookies.