quoteInto example

$sErrorMessages$sErrorFlag] = $this->eventManager->filter(
                'Shopware_Modules_Admin_Login_FilterResult',
                [$sErrorMessages$sErrorFlag],
                ['subject' => $this, 'email' => null, 'password' => null, 'error' => $sErrorMessages]
            );

            return ['sErrorFlag' => $sErrorFlag, 'sErrorMessages' => $sErrorMessages];
        }

        $addScopeSql = '';
        if ($this->scopedRegistration == true) {
            $addScopeSql = $this->db->quoteInto(' AND subshopID = ? ', $this->subshopId);
        }

        // When working with a pre-hashed password, we need to limit the getUser query by password,         // as there might be multiple users with the same mail address (accountmode = 1).         $preHashedSql = '';
        if ($isPreHashed) {
            $preHashedSql = $this->db->quoteInto(' AND password = ? ', $password);
        }

        if ($ignoreAccountMode) {
            $sql = ' SELECT id, customergroup, password, encoder, password_change_date FROM s_user WHERE email = ? AND active=1 AND (lockeduntil < now() OR lockeduntil IS NULL) '

    protected function generateVoucherCodes($voucherId$numberOfUnits$codePattern)
    {
        $values = [];
        // wrote in standard sql cause in this case its way faster than doctrine models         $sql = 'INSERT IGNORE INTO s_emarketing_voucher_codes (voucherID, code) VALUES';
        for ($i = 1; $i <= $numberOfUnits; ++$i) {
            $code = $this->generateCode($codePattern);
            $values[] = Shopware()->Db()->quoteInto('(?)', [$voucherId$code]);
            // send the query every each 10000 times             if ($i % 10000 == 0 || $numberOfUnits == $i) {
                Shopware()->Db()->query($sql . implode(',', $values));
                $values = [];
            }
        }
    }

    /** * Helper function to get access to the voucher repository. * * @return Repository */
public function rehash($plaintext$hash$encoderName)
    {
        $newHash = Shopware()->PasswordEncoder()->reencodePassword($plaintext$hash$encoderName);

        if ($newHash === $hash) {
            return;
        }

        $this->_zendDb->update(
            $this->_tableName,
            [$this->_credentialColumn => $newHash],
            $this->_zendDb->quoteInto(
                $this->_zendDb->quoteIdentifier($this->_identityColumn, true) . ' = ?',
                $this->_identity
            )
        );
    }

    /** * Used for updating to new algorithm for the future * * @param string $plaintext * @param string $defaultEncoderName * * @return void */


        // Filter by shop         if (!empty($shopId)) {
            $stmt->where('s.shopID = ?', $shopId);
        }

        // Filter by namespace         if (!empty($namespace)) {
            $namespaceWildcard = $namespace . '/%';
            $stmt->where(
                $this->database->quoteInto('s.namespace LIKE ?', $namespace) .
                ' OR ' .
                $this->database->quoteInto('s.namespace LIKE ?', $namespaceWildcard)
            );

            $secondStmt->where(
                $this->database->quoteInto('s1.namespace LIKE ?', $namespace) .
                ' OR ' .
                $this->database->quoteInto('s1.namespace LIKE ?', $namespaceWildcard)
            );
        }

        
$db = $this->_getTable()->getAdapter();
        $primaryKey = $this->_getPrimaryKey($useDirty);
        $info = $this->_getTable()->info();
        $metadata = $info[Zend_Db_Table_Abstract::METADATA];

        // retrieve recently updated row using primary keys         $where = array();
        foreach ($primaryKey as $column => $value) {
            $tableName = $db->quoteIdentifier($info[Zend_Db_Table_Abstract::NAME], true);
            $type = $metadata[$column]['DATA_TYPE'];
            $columnName = $db->quoteIdentifier($column, true);
            $where[] = $db->quoteInto("{$tableName}.{$columnName} = ?", $value$type);
        }
        return $where;
    }

    /** * Refreshes properties from the database. * * @return void */
    protected function _refresh()
    {
        

    protected function _authenticateCreateSelect()
    {
        // build credential expression         if (empty($this->_credentialTreatment) || (strpos($this->_credentialTreatment, '?') === false)) {
            $this->_credentialTreatment = '?';
        }

        $credentialExpression = new Zend_Db_Expr(
            '(CASE WHEN ' .
            $this->_zendDb->quoteInto(
                $this->_zendDb->quoteIdentifier($this->_credentialColumn, true)
                . ' = ' . $this->_credentialTreatment, $this->_credential
                )
            . ' THEN 1 ELSE 0 END) AS '
            . $this->_zendDb->quoteIdentifier(
                $this->_zendDb->foldCase('zend_auth_credential_match')
                )
            );

        // get select         $dbSelect = clone $this->getDbSelect();
        

    public function getMailing($id = null)
    {
        if (!empty($id)) {
            $where = Shopware()->Db()->quoteInto('cm.id=?', $id);
        } else {
            $where = 'cm.status=1 ';
        }
        $sql = 'SELECT cm.*, ct.path as template FROM s_campaigns_mailings cm, s_campaigns_templates ct WHERE ct.id=cm.templateID AND ' . $where . ' AND (`timed_delivery` <= NOW() OR `timed_delivery` IS NULL)';

        return Shopware()->Db()->fetchRow($sql);
    }
switch ($map[self::ON_UPDATE]) {
                    case self::CASCADE:
                        $newRefs = array();
                        $where = array();
                        for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
                            $col = $this->_db->foldCase($map[self::COLUMNS][$i]);
                            $refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
                            if (array_key_exists($refCol$newPrimaryKey)) {
                                $newRefs[$col] = $newPrimaryKey[$refCol];
                            }
                            $type = $this->_metadata[$col]['DATA_TYPE'];
                            $where[] = $this->_db->quoteInto(
                                $this->_db->quoteIdentifier($col, true) . ' = ?',
                                $oldPrimaryKey[$refCol]$type);
                        }
                        $rowsAffected += $this->update($newRefs$where);
                        break;
                    default:
                        // no action                         break;
                }
            }
        }
        

    public function sGetAmountRestrictedArticles($articles$supplier)
    {
        if (!\is_array($articles) && empty($supplier)) {
            return $this->sGetAmountArticles();
        }

        $extraConditions = [];
        if (!empty($articles) && \is_array($articles)) {
            $extraConditions[] = $this->db->quoteInto('ordernumber IN (?) ', $articles);
        }
        if (!empty($supplier)) {
            $extraConditions[] = $this->db->quoteInto('s_articles.supplierID = ?', $supplier);
        }

        if (\count($extraConditions)) {
            $sqlExtra = ' AND ( ' . implode(' OR ', $extraConditions) . ' ) ';
        } else {
            $sqlExtra = '';
        }

        

    public function having($cond$value = null, $type = null)
    {
        if ($value !== null) {
            $cond = $this->_adapter->quoteInto($cond$value$type);
        }

        if ($this->_parts[self::HAVING]) {
            $this->_parts[self::HAVING][] = self::SQL_AND . " ($cond)";
        } else {
            $this->_parts[self::HAVING][] = "($cond)";
        }

        return $this;
    }

    

        if (empty($fields)) {
            return $this;
        }

        $where = [];
        $updateData = [];
        $insertData = [];

        if ($this->_namespaceColumn !== null) {
            $insertData[$this->_namespaceColumn] = $name;
            $where[] = $db->quoteInto($this->_namespaceColumn . '=?', $name);
        }
        if ($this->_updatedColumn !== null) {
            $updateData[$this->_updatedColumn] = new Zend_Date();
            $insertData[$this->_updatedColumn] = new Zend_Date();
        }
        if ($this->_createdColumn !== null) {
            $insertData[$this->_createdColumn] = new Zend_Date();
        }

        if (\is_array($this->_sectionColumn)) {
            foreach ($this->_sectionColumn as $key => $sectionColumn) {
                

        foreach ($where as $cond => &$term) {
            // is $cond an int? (i.e. Not a condition)             if (is_int($cond)) {
                // $term is the full condition                 if ($term instanceof Zend_Db_Expr) {
                    $term = $term->__toString();
                }
            } else {
                // $cond is the condition with placeholder,                 // and $term is quoted into the condition                 $term = $this->quoteInto($cond$term);
            }
            $term = '(' . $term . ')';
        }

        $where = implode(' AND ', $where);

        return $where;
    }

    /** * Quote a raw string. * * @param string $value Raw string * * @return string Quoted string */
/** * Disables an account until a given date. * $date has to be an Zend_Date object * * @return Enlight_Components_Auth_Adapter_DbTable */
    public function setLockedUntil(Zend_Date $date)
    {
        $this->lockedUntil = $date;
        $this->updateLockUntilDate($date);
        $this->addCondition($this->_zendDb->quoteInto(
            $this->_zendDb->quoteIdentifier($this->lockedUntilColumn, true) . ' <= ?', Zend_Date::now()
        ));

        return $this;
    }

    /** * Gets the date until an account has been disabled. Returns a Zend_Date * * @return Zend_Date */
    
Home | Imprint | This part of the site doesn't use cookies.