Connection::prepareSqlStatement

Platform preparing a Sql statement.

@param string $sqlStatement Sql Statement to be prepared.
@param array  $options      Preparing Sql statement options.

@return string
10235
protected function platformPrepareSqlStatement($sqlStatement, array $options = [])
    {
        // Sqlite3::changes() returns 0 for "DELETE FROM TABLE" queries. This hack
        // modifies the query so that it a proper number of affected rows is returned.
        if ($this->isDeleteHack === true && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sqlStatement)) {
            return trim($sqlStatement) . ' WHERE 1=1';
        }

        return $sqlStatement;
    }
686312
public function prepare(string $sql, array $params = []): Statement
    {
        if (!$stmt = $this->connection->prepare($sql)) {
            $error = [
                'error' => $this->connection->error,
                'errno' => $this->connection->errno,
                'sqlstate' => $this->connection->sqlstate
            ];

            throw new SqlException('Failed to prepare statement', [$error], $sql, $params);
        }

        if (!empty($params)) {
            if (!$stmt->bind_param(self::getMysqlParamTypes($params), ...$params)) {
                throw new SqlException('Failed to bind params', $stmt->error_list, $sql, $params);
            }
        }

        return new Statement($stmt, $this->usedPrepare, $sql, $params);
    }
105608
public function fetch($sql, array $params, array $options = array())
    {
        $sth = $this->run($sql, $params);
        $result = $sth->fetch(PDO::FETCH_ASSOC);

        $this->prepareResult($result, $options);
        return empty($result) ? array() : (array) $result;
    }
362701
public function prepare($sql, $driverOptions = [])
    {
        $this->placeholders = $this->types = [];
        $sql = preg_replace_callback(static::PLACEHOLDER_REGEX, function ($matches) {
            $name = $matches[2];
            if (!isset($this->types[$name])) {
                $this->types[$name] = static::$typeMap[$matches[1]];
            }
            $this->placeholders[] = $name;

            return '?';
        }, $sql);

        return parent::prepare($sql, $driverOptions);
    }
126859
@Override
    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
    {
        if ((resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE || resultSetType == ResultSet.TYPE_FORWARD_ONLY) &&
                resultSetConcurrency == ResultSet.CONCUR_READ_ONLY) {
            return prepareStatement(sql);
        }
        checkClosed();
        throw SQLError.noSupport();
    }
1343325
@Override
    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
    {
        checkClosed();
        throw SQLError.noSupport();
    }
1095491
public PreparedStatement prepareStatement(final String sql) throws SQLException {
        if (parameterizedBatchHandlerFactory == null) {
            this.parameterizedBatchHandlerFactory = new DefaultParameterizedBatchHandlerFactory();
        }
        final String strippedQuery = Utils.stripQuery(sql);
        return new DrizzlePreparedStatement(protocol,
                this,
                strippedQuery,
                queryFactory,
                parameterizedBatchHandlerFactory.get(strippedQuery, protocol));
    }
407686
public function prepare($sql, $driver_options=array())
    {

        $md5 = md5($sql);

        if(isset($this->prepared_sql[$md5])){
            return $this->prepared_sql[$md5];
        }

        $stmt = parent::prepare($sql, $driver_options);
        $this->prepared_sql[$md5] = $stmt;
        return $stmt;
    }
284288
public PreparedStatement prepareStatement(final String sql, 
                                              final int autoGeneratedKeys) 
        throws SQLException {

        checkClosed();

        return new acolyte.jdbc.
            PreparedStatement(this, sql, autoGeneratedKeys, null, null,
                              this.handler.getStatementHandler());

    }
1194707
public PreparedStatement prepareStatement(final String sql) throws SQLException {
    return internalPrepareStatement(sql,
        ResultSet.TYPE_FORWARD_ONLY,
        ResultSet.CONCUR_READ_ONLY,
        Statement.NO_GENERATED_KEYS);
  }
480421
private static function executePrepareQuery($sqlstatement, array $data = [])
    {
        $pdostatement = static::$adapter
            ->getConnection()
            ->prepare($sqlstatement);

        static::$adapter->bind(
            $pdostatement,
            Sanitize::make($data, true)
        );

        $pdostatement->execute();

        $r = $pdostatement->rowCount();

        return $r;
    }
383832
public StatementInfo prepareStatementInfo() throws SQLException {
		List<ArgumentHolder> argList = new ArrayList<ArgumentHolder>();
		String statement = buildStatementString(argList);
		return new StatementInfo(statement, argList);
	}
337152
public function prepare($sql, $options = null)
    {

        $md5 = md5($sql);

        if (isset($this->prepared_sql[$md5])) {
            return $this->prepared_sql[$md5];
        }

        //$this->writeToLog("Preparing: ".$sql);
        $stmt = parent::prepare($sql);
        $this->prepared_sql[$md5] = $stmt;
        return $stmt;
    }
187306
protected PreparedStatement getPreparedStatement(final SqlContext sqlContext) throws SQLException {
		PreparedStatement stmt = ((LocalTransactionManager) transactionManager).getPreparedStatement(sqlContext);
		// プロパティ設定
		applyProperties(stmt);
		return stmt;
	}
702960
public function throwExceptionIfErrors($sqlStatement)
    {
        if ((int) $sqlStatement->errorCode()) {
            throw new \Exception(
                print_r($sqlStatement->errorInfo(), true)
            );
        }

        return false;
    }
280657
@Override
    public PoolablePreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
        return new PoolablePreparedStatement(internalConn.prepareStatement(sql, columnIndexes), this, null);
    }
952205
protected function prepareStatement($db, $query)
    {
        try {
            $stmt = $db->prepare($query);
        } catch (\Exception $e) {
            $stmt = false;
        }

        if (false === $stmt) {
            throw new \RuntimeException('The database cannot successfully prepare the statement');
        }

        return $stmt;
    }