yajra / pdo-via-oci8

PHP PDO_OCI functions via OCI8 extension
Other
88 stars 61 forks source link

query 4th attribute can also be null #62

Closed istaveren closed 5 years ago

istaveren commented 5 years ago

Summary of problem or feature request

pdo->query has multiple implementations. But the 4th parameter can be null. See https://www.php.net/manual/en/pdo.query.php

With the current solution I get this error when I passing in null:

TypeError: Argument 4 passed to Yajra\Pdo\Oci8::query() must be of the type array, null given,

Code snippet of problem

$con->query('SELECT table_name FROM user_tables', null, null, null);

Solution

Match the docblock that tells it can be array|null Also see setFetchMode.

    /**
     * Executes an SQL statement, returning the results as a
     * Yajra\Pdo\Oci8\Statement object.
     *
     * @param string $statement The SQL statement to prepare and execute.
     * @param int|null $fetchMode The fetch mode must be one of the
     *   PDO::FETCH_* constants.
     * @param mixed|null $modeArg Column number, class name or object.
     * @param array|null $ctorArgs Constructor arguments.
     * @return Statement
     */
    public function query($statement, $fetchMode = null, $modeArg = null, $ctorArgs = null)
yajra commented 5 years ago

Fixed via #62.