src/main/php/pdo/PdoDatabaseConnection.php
public function query(string $sql, array $driverOptions = []): QueryResult
    {
        if (null === $this->pdo) {
            $this->connect();
        }

        try {
            if (!isset($driverOptions['fetchMode'])) {
                return new PdoQueryResult($this->pdo->query($sql));
            }

            switch ($driverOptions['fetchMode']) {
                case PDO::FETCH_COLUMN:
                    if (!isset($driverOptions['colNo'])) {
                        throw new \InvalidArgumentException(
                                'Fetch mode COLUMN requires driver option colNo.'
                        );
                    }

                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode'],
                            $driverOptions['colNo']
                    );
                    break;

                case PDO::FETCH_INTO:
                    if (!isset($driverOptions['object'])) {
                        throw new \InvalidArgumentException(
                                'Fetch mode INTO requires driver option object.'
                        );
                    }

                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode'],
                            $driverOptions['object']
                    );
                    break;

                case PDO::FETCH_CLASS:
                    if (!isset($driverOptions['classname'])) {
                        throw new \InvalidArgumentException(
                                'Fetch mode CLASS requires driver option classname.'
                        );
                    }

                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode'],
                            $driverOptions['classname'],
                            $driverOptions['ctorargs'] ?? []
                    );
                    break;

                default:
                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode']
                    );
            }

            return new PdoQueryResult($pdoStatement);
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }
    }
public function query(string $sql, array $driverOptions = []): QueryResult
    {
        if (null === $this->pdo) {
            $this->connect();
        }

        try {
            if (!isset($driverOptions['fetchMode'])) {
                return new PdoQueryResult($this->pdo->query($sql));
            }

            switch ($driverOptions['fetchMode']) {
                case PDO::FETCH_COLUMN:
                    if (!isset($driverOptions['colNo'])) {
                        throw new \InvalidArgumentException(
                                'Fetch mode COLUMN requires driver option colNo.'
                        );
                    }

                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode'],
                            $driverOptions['colNo']
                    );
                    break;

                case PDO::FETCH_INTO:
                    if (!isset($driverOptions['object'])) {
                        throw new \InvalidArgumentException(
                                'Fetch mode INTO requires driver option object.'
                        );
                    }

                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode'],
                            $driverOptions['object']
                    );
                    break;

                case PDO::FETCH_CLASS:
                    if (!isset($driverOptions['classname'])) {
                        throw new \InvalidArgumentException(
                                'Fetch mode CLASS requires driver option classname.'
                        );
                    }

                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode'],
                            $driverOptions['classname'],
                            $driverOptions['ctorargs'] ?? []
                    );
                    break;

                default:
                    $pdoStatement = $this->pdo->query(
                            $sql,
                            $driverOptions['fetchMode']
                    );
            }

            return new PdoQueryResult($pdoStatement);
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }
    }
public function query ( string $ sql , array $ driverOptions = [ ] ) : QueryResult { if ( null === $ this -> pdo ) { $ this -> connect ( ) ; } try { if ( ! isset ( $ driverOptions [ 'fetchMode' ] ) ) { return new PdoQueryResult ( $ this -> pdo -> query ( $ sql ) ) ; } switch ( $ driverOptions [ 'fetchMode' ] ) { case PDO :: FETCH_COLUMN : if ( ! isset ( $ driverOptions [ 'colNo' ] ) ) { throw new \ InvalidArgumentException ( 'Fetch mode COLUMN requires driver option colNo.' ) ; } $ pdoStatement = $ this -> pdo -> query ( $ sql , $ driverOptions [ 'fetchMode' ] , $ driverOptions [ 'colNo' ] ) ; break ; case PDO :: FETCH_INTO : if ( ! isset ( $ driverOptions [ 'object' ] ) ) { throw new \ InvalidArgumentException ( 'Fetch mode INTO requires driver option object.' ) ; } $ pdoStatement = $ this -> pdo -> query ( $ sql , $ driverOptions [ 'fetchMode' ] , $ driverOptions [ 'object' ] ) ; break ; case PDO :: FETCH_CLASS : if ( ! isset ( $ driverOptions [ 'classname' ] ) ) { throw new \ InvalidArgumentException ( 'Fetch mode CLASS requires driver option classname.' ) ; } $ pdoStatement = $ this -> pdo -> query ( $ sql , $ driverOptions [ 'fetchMode' ] , $ driverOptions [ 'classname' ] , $ driverOptions [ 'ctorargs' ] ?? [ ] ) ; break ; default : $ pdoStatement = $ this -> pdo -> query ( $ sql , $ driverOptions [ 'fetchMode' ] ) ; } return new PdoQueryResult ( $ pdoStatement ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } }
executes a SQL statement

The driver options can be:
<code>
fetchMode => one of the PDO::FETCH_* constants
colNo     => if fetchMode == PDO::FETCH_COLUMN this denotes the column number to fetch
object    => if fetchMode == PDO::FETCH_INTO this denotes the object to fetch the data into
classname => if fetchMode == PDO::FETCH_CLASS this denotes the class to create and fetch the data into
ctorargs  => (optional) if fetchMode == PDO::FETCH_CLASS this denotes the list of arguments for the constructor of the class to create and fetch the data into
</code>

@param   string  $sql            the sql query to use
@param   array   $driverOptions  optional  how to fetch the data
@return  \stubbles\db\pdo\PdoQueryResult
@throws  \stubbles\db\DatabaseException
@throws  \InvalidArgumentException
@see     http://php.net/pdo-query
@see     http://php.net/pdostatement-setfetchmode for the details on the fetch mode options
executes a SQL statement