Prepare a statement and return a PDOStatement-like object.

@param  string  $sql  SQL query
@return Zend_Db_Statement_Mysqli
345927
public function prepare($sql)
    {
        $this->_connect();
        if ($this->_stmt) {
            $this->_stmt->close();
        }
        $stmtClass = $this->_defaultStmtClass;
        if (!class_exists($stmtClass)) {
            // require_once 'Zend/Loader.php';
            Zend_Loader::loadClass($stmtClass);
        }
        $stmt = new $stmtClass($this, $sql);
        if ($stmt === false) {
            return false;
        }
        $stmt->setFetchMode($this->_fetchMode);
        $this->_stmt = $stmt;
        return $stmt;
    }
249309
public function exec($sql)
    {
        try {
            $stmt = $this->query($sql);
            $rows = $stmt->rowCount();
            $stmt->closeCursor();
            return $rows;
        } catch (\Exception $e) {
            throw new \PDOException($e->getMessage());
        }
        return $this;
    }
1344234
public function exec(string $sql)
    {
        try {
            return $this->dbh->exec($sql);
        } catch (\PDOException $e) {
            die("Error: " . $e->getMessage());
        }
    }
252129
public function query(string $sql, array $params = []): Statement
    {
        $this->usedPrepare = false;
        $stmt = $this->prepare($sql, $params);
        $this->usedPrepare = true;
        $stmt->execute();
        return $stmt;
    }
431436
public function prepare()
    {
        if (null === $this->statement) {
            $this->statement = $this->db->prepare($this->getSql());
        }

        return $this;
    }
261340
protected function prepareConverters($sql)
    {
        foreach ($this->getParametersType($sql) as $index => $type) {
            if ($type === '') {
                $this->converters[$index] = null;
            } else {
                $converter = $this
                    ->getSession()
                    ->getClientUsingPooler('converter', $type)
                    ->getConverter()
                    ;

                $this->converters[$index] = function ($value) use ($converter, $type) {
                    return $converter->toPgStandardFormat($value, $type, $this->getSession());
                };
            }
        }

        return $this;
    }
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;
    }
361381
public function prepare( $sql, $values ) {
		/** @var \wpdb $wpdb */
		global $wpdb;

		return empty( $values ) ? $sql : $wpdb->prepare( $sql, $values );
	}
1255141
protected function execSQL($sql)
    {
        // Check and ignore empty statements
        if (trim($sql) == "") {
            return;
        }

        try {
            $this->totalSql++;

            $this->statement = $this->conn->query($sql);
            $this->log($this->statement->rowCount() . " rows affected", Project::MSG_VERBOSE);

            // only call processResults() for statements that return actual data (such as 'select')
            if ($this->statement->columnCount() > 0) {
                $this->processResults();
            }

            $this->statement->closeCursor();
            $this->statement = null;

            $this->goodSql++;
        } catch (PDOException $e) {
            $this->log("Failed to execute: " . $sql, Project::MSG_ERR);
            if ($this->onError != "continue") {
                throw new BuildException("Failed to execute SQL", $e);
            }
            $this->log($e->getMessage(), Project::MSG_ERR);
        }
    }
676801
function prepare($sql, $driver_options = [])
    {
//        if (isset($this->statements[$sql])){
//            return $this->statements[$sql];
//        }
        if ($this->trace_sql || $this->trace_count){
            $stmt = parent::prepare($this->addPrefixes($sql), $driver_options);
            if ($stmt instanceof PDOStatement){
                return /*$this->statements[$sql] = */new DBStatementDebug($stmt, $this->trace_sql, $this->trace_count, $this->slow_query);
            }else{
                throw new Error('PDO does not return PDOStatement');
            }
        }
        return /*$this->statements[$sql] = */parent::prepare($this->addPrefixes($sql), $driver_options);
    }
730556
public function prepare($query)
    {
        $this->connect();
        $isObject = $query instanceof Query;
        $statement = $this->_connection->prepare($isObject ? $query->sql() : $query);

        return new PDOStatement($statement, $this);
    }
239648
public function statement($sql, $bindings = array())
		{
			list($statement, $result) = $this->execute($sql, $bindings);
			return $result;
		}
1305621
function _prepareStatement()
    {
        $this->_statement = $this->_db->prepare($this->_sql);

        /* Return success if we didn't generate an error. */
        return (DB::isError($this->_statement) === false);
    }
884659
protected function execute($sql)
    {
        $this->lastQuery = $sql;

        $this->debugLog(sprintf('Executing SQL: %s', $sql));

        $this->sqlStatement = $this->getConnection()->prepare($sql, []);
        $this->sqlStatement->execute();
        $this->lastId = $this->connection->lastInsertId(sprintf('%s_id_seq', $this->getEntity()));

        // If their is an id, save it!
        if ($this->lastId) {
            $this->handleLastId($this->getEntity(), $this->lastId);
        }

        return $this->sqlStatement;
    }
589728
protected function _prepare($sql)
    {
        $connection = $this->_adapter->getConnection();
        $this->_stmt = @oci_parse($connection, $sql);
        if (!$this->_stmt) {
            /**
             * @see Zend_Db_Statement_Oracle_Exception
             */
            // require_once 'Zend/Db/Statement/Oracle/Exception.php';
            throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection));
        }
    }
1095061
public function query($sql)
    {
        return $this->getDisconnectRetry()->run(function () use ($sql) {
            $statement = $this->prepare($sql);
            $statement->execute();

            return $statement;
        });
    }
664819
protected function execSQL($sql)
    {
        // Check and ignore empty statements
        if (trim($sql) == "") {
            return;
        }

        try {
            $this->totalSql++;

            if (!$this->autocommit) {
                $this->conn->beginTransaction();
            }

            $stmt = $this->conn->prepare($sql);
            $this->log(sprintf('    Executing statement "%s"', $sql), Project::MSG_VERBOSE);
            $stmt->execute();
            $this->log(sprintf('    %d rows affected', $stmt->rowCount()), Project::MSG_VERBOSE);

            if (!$this->autocommit) {
                $this->conn->commit();
            }

            $this->goodSql++;
        } catch (PDOException $e) {
            $this->log("Failed to execute: " . $sql, Project::MSG_ERR);
            if ($this->onError != "continue") {
                throw $e;
            }
            $this->log($e->getMessage(), Project::MSG_ERR);
        }
    }