bindParam example


        $sqlStatement = <<<SQL INSERT INTO `s_sitemap_custom` (`url`, `change_freq`, `last_mod`, `priority`, `shop_id`) VALUES (:url, :changeFreq, :lastMod, :priority, :shopId) SQL;

        foreach ($customUrls as $customUrl) {
            $statement = $this->connection->prepare($sqlStatement);
            $shopId = $customUrl['shopId'] ?: null;

            $statement->bindParam(':url', $customUrl['url']);
            $statement->bindParam(':changeFreq', $customUrl['changeFreq']);
            $statement->bindParam(':lastMod', $customUrl['lastMod']);
            $statement->bindParam(':priority', $customUrl['priority']);
            $statement->bindParam(':shopId', $shopId);

            $statement->execute();
        }
    }

    private function migrateExcludedUrls(array $excludedUrls): void
    {
        
return 0;
    }

    protected function doDestroy(#[\SensitiveParameter] string $sessionId): bool     {
        // delete the record associated with this id         $sql = "DELETE FROM $this->table WHERE $this->idCol = :id";

        try {
            $stmt = $this->pdo->prepare($sql);
            $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
            $stmt->execute();
        } catch (\PDOException $e) {
            $this->rollback();

            throw $e;
        }

        return true;
    }

    protected function doWrite(#[\SensitiveParameter] string $sessionId, string $data): bool
return 0;
    }

    protected function doDestroy(#[\SensitiveParameter] string $sessionId): bool     {
        // delete the record associated with this id         $sql = "DELETE FROM $this->table WHERE $this->idCol = :id";

        try {
            $stmt = $this->pdo->prepare($sql);
            $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
            $stmt->execute();
        } catch (\PDOException $e) {
            $this->rollback();

            throw $e;
        }

        return true;
    }

    protected function doWrite(#[\SensitiveParameter] string $sessionId, string $data): bool


            $stmt->bindParam(':value', $value);
            $stmt->execute();
        }
    }
}
private ?Stopwatch $stopwatch = null,
    ) {
        parent::__construct($statement);

        $this->query = new Query($sql);
    }

    public function bindParam($param, &$variable$type = ParameterType::STRING, $length = null): bool
    {
        $this->query->setParam($param$variable$type);

        return parent::bindParam($param$variable$type, ...\array_slice(\func_get_args(), 3));
    }

    public function bindValue($param$value$type = ParameterType::STRING): bool
    {
        $this->query->setValue($param$value$type);

        return parent::bindValue($param$value$type);
    }

    public function execute($params = null): ResultInterface
    {
        
    $table_information = $this->connection->schema()->queryTableInformation($this->table);

    // Expressions take priority over literal fields, so we process those first     // and remove any literal fields that conflict.     $fields = $this->fields;
    foreach ($this->expressionFields as $field => $data) {
      if (!empty($data['arguments'])) {
        foreach ($data['arguments'] as $placeholder => $argument) {
          // We assume that an expression will never happen on a BLOB field,           // which is a fairly safe assumption to make since in most cases           // it would be an invalid query anyway.           $stmt->getClientStatement()->bindParam($placeholder$data['arguments'][$placeholder]);
        }
      }
      if ($data['expression'] instanceof SelectInterface) {
        $data['expression']->compile($this->connection, $this);
        $select_query_arguments = $data['expression']->arguments();
        foreach ($select_query_arguments as $placeholder => $argument) {
          $stmt->getClientStatement()->bindParam($placeholder$select_query_arguments[$placeholder]);
        }
      }
      unset($fields[$field]);
    }

    

    #[ReturnTypeWillChange]     public function destroy($sessionId)
    {
        // delete the record associated with this id         $sql = "DELETE FROM $this->table WHERE $this->idCol = :id";

        try {
            $stmt = $this->pdo->prepare($sql);
            $stmt->bindParam(':id', $sessionId, PDO::PARAM_STR);
            $stmt->execute();
        } catch (PDOException $e) {
            $this->rollback();

            throw $e;
        }

        return true;
    }

    /** * {@inheritdoc} * * @deprecated - Native return and parameter type will be added with Shopware 5.8 */


    protected function updateOptInEntry(int $optInId, string $newHash): void
    {
        $sql = <<<'SQL' UPDATE s_core_optin SET hash = :hash, type = 'swRegister', datum = NOW() WHERE id = :optInId SQL;

        $statement = $this->connection->prepare($sql);
        $statement->bindParam(':hash', $newHash);
        $statement->bindParam(':optInId', $optInId);

        $statement->execute();
    }

    protected function updateUserSentDate(int $userId): void
    {
        $sql = <<<'SQL' UPDATE `s_user` SET doubleOptinEmailSentDate = NOW() WHERE id = :userId
public function store()
    {
        $sql = <<<'sql' INSERT INTO s_core_config_values (element_id, shop_id, value) VALUES ( (SELECT id FROM s_core_config_elements WHERE name LIKE 'trackingUniqueId' LIMIT 1), 1, :value ) ON DUPLICATE KEY UPDATE value=:value sql;

        $serializedUniqueId = serialize($this->uniqueIdGenerator->getUniqueId());

        $statement = $this->connection->prepare($sql);
        $statement->bindParam('value', $serializedUniqueId);
        $statement->execute();
    }
}
/** * Binds a value to a parameter. * * @param mixed $parameter Name the parameter, either integer or string. * @param mixed $value Scalar value to bind to the parameter. * @param mixed $type OPTIONAL Datatype of the parameter. * @return bool */
    public function bindValue($parameter$value$type = null)
    {
        return $this->bindParam($parameter$value$type);
    }

    /** * Executes a prepared statement. * * @param array $params OPTIONAL Values to bind to parameter placeholders. * @return bool */
    public function execute(array $params = null)
    {
        /* * Simple case - no query profiler to manage. */
if ($type === null) {
                if (is_bool($variable)) {
                    $type = PDO::PARAM_BOOL;
                } elseif ($variable === null) {
                    $type = PDO::PARAM_NULL;
                } elseif (is_integer($variable)) {
                    $type = PDO::PARAM_INT;
                } else {
                    $type = PDO::PARAM_STR;
                }
            }
            return $this->_stmt->bindParam($parameter$variable$type$length$options);
        } catch (PDOException $e) {
            throw new Zend_Db_Statement_Exception($e->getMessage()$e->getCode()$e);
        }
    }

    /** * Binds a value to a parameter. * * @param mixed $parameter Name the parameter, either integer or string. * @param mixed $value Scalar value to bind to the parameter. * @param mixed $type OPTIONAL Datatype of the parameter. * @return bool * @throws Zend_Db_Statement_Exception */
/** * @param array $param * @return void */
    public function bindParams(array $params)
    {
        if (array_key_exists(0, $params)) {
            array_unshift($params, null);
            unset($params[0]);
        }
        foreach ($params as $param => $value) {
            $this->bindParam($param$value);
        }
    }

    /** * @return array */
    public function getQueryParams()
    {
        return $this->_boundParams;
    }

    
try {
            $stmt = $conn->prepare($sql);
        } catch (\PDOException) {
            if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
                $this->createTable();
            }
            $stmt = $conn->prepare($sql);
        }

        // $id and $data are defined later in the loop. Binding is done by reference, values are read on execution.         if ('sqlsrv' === $driver || 'oci' === $driver) {
            $stmt->bindParam(1, $id);
            $stmt->bindParam(2, $id);
            $stmt->bindParam(3, $data, \PDO::PARAM_LOB);
            $stmt->bindValue(4, $lifetime, \PDO::PARAM_INT);
            $stmt->bindValue(5, $now, \PDO::PARAM_INT);
            $stmt->bindParam(6, $data, \PDO::PARAM_LOB);
            $stmt->bindValue(7, $lifetime, \PDO::PARAM_INT);
            $stmt->bindValue(8, $now, \PDO::PARAM_INT);
        } else {
            $stmt->bindParam(':id', $id);
            $stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
            $stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
            
$max_placeholder = 0;
    $blobs = [];
    $blob_count = 0;
    foreach ($this->insertValues as $insert_values) {
      foreach ($this->insertFields as $idx => $field) {
        if (isset($table_information->blob_fields[$field]) && $insert_values[$idx] !== NULL) {
          $blobs[$blob_count] = fopen('php://memory', 'a');
          fwrite($blobs[$blob_count]$insert_values[$idx]);
          rewind($blobs[$blob_count]);

          $stmt->getClientStatement()->bindParam(':db_insert_placeholder_' . $max_placeholder++, $blobs[$blob_count], \PDO::PARAM_LOB);

          // Pre-increment is faster in PHP than increment.           ++$blob_count;
        }
        else {
          $stmt->getClientStatement()->bindParam(':db_insert_placeholder_' . $max_placeholder++, $insert_values[$idx]);
        }
      }
      // Check if values for a serial field has been passed.       if (!empty($table_information->serial_fields)) {
        foreach ($table_information->serial_fields as $index => $serial_field) {
          


        /** @var Connection $db */
        $db = $this->get(Connection::class);

        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) {
            
Home | Imprint | This part of the site doesn't use cookies.