Creates statement from procedure.

@param  string      $procedureName
@param  array       $bindings
@param  string|bool $cursorName
@return PDOStatement
434027
public function createStatementFromProcedure($procedureName, array $bindings, $cursorName = false)
    {
        $sql = $this->createSqlFromProcedure($procedureName, $bindings, $cursorName);

        return $this->getPdo()->prepare($sql);
    }
51056
public function write(array $bindings=null, $returnAffectedRows=null)
    {

        $returnAffectedRows = $returnAffectedRows !== null ? $returnAffectedRows : $this->returnAffected;

        $bindings = is_array($bindings) ? $bindings : $this->bindings;

        $this->bindAndRun($bindings);

        if (!$returnAffectedRows) {
            return null;
        }

        return $this->statement->rowCount();
    }
418332
public function cursor( $query, $bindings = [], $useReadPdo = true )
	{
		$statement = $this->run( $query, $bindings, function ( $me, $query, $bindings ) use ( $useReadPdo )
		{
			if ( $me->pretending() )
			{
				return [];
			}

			$statement = $this->getPdoForSelect( $useReadPdo )->prepare( $query );

			$fetchMode = $me->getFetchMode();
			$fetchArgument = $me->getFetchArgument();

			if ( $fetchMode === PDO::FETCH_CLASS && !isset( $fetchArgument ) )
			{
				$fetchArgument = 'StdClass';
			}

			if ( isset( $fetchArgument ) )
			{
				$statement->setFetchMode( $fetchMode, $fetchArgument, $me->getFetchConstructorArgument() );
			}
			else
			{
				$statement->setFetchMode( $fetchMode );
			}

			$statement->execute( $me->prepareBindings( $bindings ) );

			return $statement;
		} );

		while ( $record = $statement->fetch() )
		{
			yield $record;
		}
	}
105210
public function query(string $query, array $bindings = null): Query
    {
        $this->lastQuery = new Query($query, $bindings, $this->configKey);
        return $this->lastQuery;
    }
712039
public function setSqlStatement($sqlStatement, array $SqlBinds = [])
    {
        $this->sqlStatement = $sqlStatement;
        $this->sqlBinds = $SqlBinds;

        return $this;
    }
777516
public function insert($query, $bindings = [])
    {
        try {
            $this->statement($query, $bindings);

            return true;
        } catch (\Exception $e) {
            throw new InternalServerErrorException('Insert failed. ' . $e->getMessage());
        }
    }
1306073
public function select($query, $bindings = [], $useReadPdo = true)
    {
        $query .= ' ALLOW FILTERING';

        return $this->statement($query, $bindings);
    }
6107
public function affectingStatement($query, $bindings = [])
    {
        return $this->run($query, $bindings, function ($query, $bindings) {
            if ($this->pretending()) {
                return 0;
            }

            // For update or delete statements, we want to get the number of rows affected
            // by the statement and return that back to the developer. We'll first need
            // to execute the statement and then we'll use PDO to fetch the affected.
            $statement = $this->getPdo()->prepare($query);

            $this->bindValues($statement, $this->prepareBindings($bindings));

            $statement->execute();

            return $statement->rowCount();
        });
    }
56311
public function execXMLStoredProcedure($conn, $sql, $bindArray)
    {

        $internalKey = $bindArray['internalKey'];
        $controlKey = $bindArray['controlKey'];
        $inputXml = $bindArray['inputXml'];
        $outputXml = $bindArray['outputXml'];

        // @todo see why error doesn't properly bubble up to top level.
        $crsr = @db2_prepare($conn, $sql);
        if (!$crsr) {
            $this->setStmtError();
            return false;
        }

        // stored procedure takes four parameters. Each 'name' will be bound to a real PHP variable
        $params = array(
            array('position' => 1, 'name' => "internalKey", 'inout' => DB2_PARAM_IN),
            array('position' => 2, 'name' => "controlKey",  'inout' => DB2_PARAM_IN),
            array('position' => 3, 'name' => "inputXml",    'inout' => DB2_PARAM_IN),
            array('position' => 4, 'name' => "outputXml",   'inout' => DB2_PARAM_OUT),
        );
        
        // bind the four parameters
        foreach ($params as $param) {
            $ret = db2_bind_param ($crsr, $param['position'], $param['name'], $param['inout']);
            if (!$ret) {
                // unable to bind a param. Set error and exit
                $this->setStmtError($crsr);
                return false;
            }
        }

        $ret = @db2_execute($crsr);
        if (!$ret) {
            // execution of XMLSERVICE stored procedure failed.
            $this->setStmtError($crsr);
            return false;
        }

        return $outputXml;
    }
407282
public function select($query, $bindings = array())
    {
        $statement  = $this->getActivePdo()->prepare($query);

        if ($statement->execute($bindings)) {
            return $statement->fetchAll($this->fetchMode);
        }

        throw new DbException("Db execute fail [{$query}]");
    }
215356
public function statement($query, $bindings = [])
    {
        return $this->run($query, $bindings, function ($query, $bindings) {
            if ($this->pretending()) {
                return true;
            }

            $statement = $this->getPdo()->prepare($query);

            $this->bindValues($statement, $this->prepareBindings($bindings));

            return $statement->execute();
        });
    }
457332
public function statement($sql, $bindings = array())
    {
        $start = microtime(true);
        $pdoStatement = $this->pdo->prepare($sql);
        foreach ($bindings as $key => $value) {
            $pdoStatement->bindValue(
                is_int($key) ? $key + 1 : $key,
                $value,
                is_int($value) || is_bool($value) ? PDO::PARAM_INT : PDO::PARAM_STR
            );
        }
        $pdoStatement->execute();
        return array($pdoStatement, microtime(true) - $start);
    }
1071192
protected function bindParameters(\PDOStatement $statement, array $parameters, $prefix = '')
    {
        foreach ($parameters as $key => $value) {
            // In case of multiple rows are given for insert statement
            if (is_array($value)) {
                $statement = $this->bindParameters($statement, $value, $prefix . $key);
            } else {
                switch (true) {
                    case is_int($value):
                        $type = \PDO::PARAM_INT;
                        break;
                    case is_bool($value):
                        $type = \PDO::PARAM_BOOL;
                        break;
                    case $value === null:
                        $type = \PDO::PARAM_NULL;
                        break;
                    case $value instanceof \DateTimeInterface:
                        $type  = \PDO::PARAM_STR;
                        $value = $value->format('Y-m-d H:i:s.u');
                        break;
                    default:
                        $type = \PDO::PARAM_STR;
                }

                $statement->bindValue($prefix . $key, $value, $type);
            }
        }

        return $statement;
    }
1130453
public function select($query, $bindings = array())
	{
		return $this->run($query, $bindings, function($me, $query, $bindings)
		{
			if ($me->pretending()) return array();

			// For select statements, we'll simply execute the query and return an array
			// of the database result set. Each element in the array will be a single
			// row from the database table, and will either be an array or objects.
			$statement = $me->getReadPdo()->prepare($query);

			$statement->execute($me->prepareBindings($bindings));

			return $statement->fetchAll($me->getFetchMode());
		});
	}
1021811
protected function provideStatement(): \PDOStatement
    {
        $sqlStatement = $this->buildStatement();
        $bindingValues = $this->statementBuilder->getBindingValues();
        return $this->prepareStatement($sqlStatement, $bindingValues);
    }
548897
public function prepare($query, array $bindings=[])
    {
        $statement = $this->statement($query);

        $this->callBeforeListeners('prepare',[$query, $bindings]);

        $prepared = (new PDOPrepared(
            $statement,
            $query,
            $this->getOption(self::RETURN_LAST_AFFECTED),
            $this->errorHandler
        ))->bind($bindings);

        $this->callAfterListeners('prepare',[$query, $bindings, $prepared]);

        return $prepared;

    }
563387
public function statement($query, $bindings = [])
    {
        $new_query = $this->bindParams($query, $bindings, true);

        return $this->unprepared($new_query);
    }