composer update
This commit is contained in:
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
@@ -27,17 +10,13 @@ use function implode;
|
||||
|
||||
/**
|
||||
* A Doctrine DBAL driver for the SAP Sybase SQL Anywhere PHP extension.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class Driver extends AbstractSQLAnywhereDriver
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \Doctrine\DBAL\DBALException if there was a problem establishing the connection.
|
||||
* @throws DBALException If there was a problem establishing the connection.
|
||||
*/
|
||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
|
||||
{
|
||||
@@ -70,15 +49,15 @@ class Driver extends AbstractSQLAnywhereDriver
|
||||
/**
|
||||
* Build the connection string for given connection parameters and driver options.
|
||||
*
|
||||
* @param string $host Host address to connect to.
|
||||
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
|
||||
* @param string $server Database server name on the host to connect to.
|
||||
* SQL Anywhere allows multiple database server instances on the same host,
|
||||
* therefore specifying the server instance name to use is mandatory.
|
||||
* @param string $dbname Name of the database on the server instance to connect to.
|
||||
* @param string $username User name to use for connection authentication.
|
||||
* @param string $password Password to use for connection authentication.
|
||||
* @param array $driverOptions Additional parameters to use for the connection.
|
||||
* @param string $host Host address to connect to.
|
||||
* @param int $port Port to use for the connection (default to SQL Anywhere standard port 2638).
|
||||
* @param string $server Database server name on the host to connect to.
|
||||
* SQL Anywhere allows multiple database server instances on the same host,
|
||||
* therefore specifying the server instance name to use is mandatory.
|
||||
* @param string $dbname Name of the database on the server instance to connect to.
|
||||
* @param string $username User name to use for connection authentication.
|
||||
* @param string $password Password to use for connection authentication.
|
||||
* @param mixed[] $driverOptions Additional parameters to use for the connection.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -91,15 +70,14 @@ class Driver extends AbstractSQLAnywhereDriver
|
||||
$server = ';ServerName=' . $server;
|
||||
}
|
||||
|
||||
return
|
||||
'HOST=' . $host . ':' . $port .
|
||||
return 'HOST=' . $host . ':' . $port .
|
||||
$server .
|
||||
';DBN=' . $dbname .
|
||||
';UID=' . $username .
|
||||
';PWD=' . $password .
|
||||
';' . implode(
|
||||
';',
|
||||
array_map(function ($key, $value) {
|
||||
array_map(static function ($key, $value) {
|
||||
return $key . '=' . $value;
|
||||
}, array_keys($driverOptions), $driverOptions)
|
||||
);
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
@@ -42,21 +25,13 @@ use function sasql_set_option;
|
||||
|
||||
/**
|
||||
* SAP Sybase SQL Anywhere implementation of the Connection interface.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
/**
|
||||
* @var resource The SQL Anywhere connection resource.
|
||||
*/
|
||||
/** @var resource The SQL Anywhere connection resource. */
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Connects to database with given connection string.
|
||||
*
|
||||
* @param string $dsn The connection string.
|
||||
@@ -68,22 +43,17 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
{
|
||||
$this->connection = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn);
|
||||
|
||||
if ( ! is_resource($this->connection)) {
|
||||
if (! is_resource($this->connection)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError();
|
||||
}
|
||||
|
||||
// Disable PHP warnings on error.
|
||||
if ( ! sasql_set_option($this->connection, 'verbose_errors', false)) {
|
||||
if (! sasql_set_option($this->connection, 'verbose_errors', false)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
// Enable auto committing by default.
|
||||
if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
// Enable exact, non-approximated row count retrieval.
|
||||
if ( ! sasql_set_option($this->connection, 'row_counts', true)) {
|
||||
if (! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +65,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
if ( ! sasql_set_option($this->connection, 'auto_commit', 'off')) {
|
||||
if (! sasql_set_option($this->connection, 'auto_commit', 'off')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -109,7 +79,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
if ( ! sasql_commit($this->connection)) {
|
||||
if (! sasql_commit($this->connection)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -139,7 +109,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function exec($statement)
|
||||
{
|
||||
if (false === sasql_real_query($this->connection, $statement)) {
|
||||
if (sasql_real_query($this->connection, $statement) === false) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -163,7 +133,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
if (null === $name) {
|
||||
if ($name === null) {
|
||||
return sasql_insert_id($this->connection);
|
||||
}
|
||||
|
||||
@@ -218,7 +188,7 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
if ( ! sasql_rollback($this->connection)) {
|
||||
if (! sasql_rollback($this->connection)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
@@ -230,13 +200,13 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
|
||||
/**
|
||||
* Ends transactional mode and enables auto commit again.
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*
|
||||
* @return bool Whether or not ending transactional mode succeeded.
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*/
|
||||
private function endTransaction()
|
||||
{
|
||||
if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
if (! sasql_set_option($this->connection, 'auto_commit', 'on')) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
|
||||
}
|
||||
|
||||
|
@@ -1,25 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractDriverException;
|
||||
use InvalidArgumentException;
|
||||
use function is_resource;
|
||||
use function sasql_error;
|
||||
use function sasql_errorcode;
|
||||
@@ -29,10 +13,6 @@ use function sasql_stmt_error;
|
||||
|
||||
/**
|
||||
* SAP Sybase SQL Anywhere driver exception.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class SQLAnywhereException extends AbstractDriverException
|
||||
{
|
||||
@@ -44,16 +24,16 @@ class SQLAnywhereException extends AbstractDriverException
|
||||
*
|
||||
* @return SQLAnywhereException
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function fromSQLAnywhereError($conn = null, $stmt = null)
|
||||
{
|
||||
if (null !== $conn && ! (is_resource($conn))) {
|
||||
throw new \InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
|
||||
if ($conn !== null && ! is_resource($conn)) {
|
||||
throw new InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
|
||||
}
|
||||
|
||||
if (null !== $stmt && ! (is_resource($stmt))) {
|
||||
throw new \InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
|
||||
if ($stmt !== null && ! is_resource($stmt)) {
|
||||
throw new InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
|
||||
}
|
||||
|
||||
$state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate();
|
||||
@@ -86,7 +66,7 @@ class SQLAnywhereException extends AbstractDriverException
|
||||
* or the last error could not be retrieved from the given
|
||||
* connection / statement resource.
|
||||
*/
|
||||
if ( ! $conn || ! $code) {
|
||||
if (! $conn || ! $code) {
|
||||
$code = sasql_errorcode();
|
||||
$message = sasql_error();
|
||||
}
|
||||
|
@@ -1,21 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLAnywhere;
|
||||
|
||||
@@ -24,9 +7,12 @@ use Doctrine\DBAL\Driver\StatementIterator;
|
||||
use Doctrine\DBAL\FetchMode;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use IteratorAggregate;
|
||||
use PDO;
|
||||
use ReflectionClass;
|
||||
use ReflectionObject;
|
||||
use stdClass;
|
||||
use const SASQL_BOTH;
|
||||
use function array_key_exists;
|
||||
use function call_user_func_array;
|
||||
use function func_get_args;
|
||||
use function func_num_args;
|
||||
use function gettype;
|
||||
@@ -52,46 +38,28 @@ use function sprintf;
|
||||
|
||||
/**
|
||||
* SAP SQL Anywhere implementation of the Statement interface.
|
||||
*
|
||||
* @author Steve Müller <st.mueller@dzh-online.de>
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.5
|
||||
*/
|
||||
class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
/**
|
||||
* @var resource The connection resource.
|
||||
*/
|
||||
/** @var resource The connection resource. */
|
||||
private $conn;
|
||||
|
||||
/**
|
||||
* @var string Name of the default class to instantiate when fetching class instances.
|
||||
*/
|
||||
/** @var string Name of the default class to instantiate when fetching class instances. */
|
||||
private $defaultFetchClass = '\stdClass';
|
||||
|
||||
/**
|
||||
* @var mixed[] Constructor arguments for the default class to instantiate when fetching class instances.
|
||||
*/
|
||||
/** @var mixed[] Constructor arguments for the default class to instantiate when fetching class instances. */
|
||||
private $defaultFetchClassCtorArgs = [];
|
||||
|
||||
/**
|
||||
* @var int Default fetch mode to use.
|
||||
*/
|
||||
/** @var int Default fetch mode to use. */
|
||||
private $defaultFetchMode = FetchMode::MIXED;
|
||||
|
||||
/**
|
||||
* @var resource The result set resource to fetch.
|
||||
*/
|
||||
/** @var resource The result set resource to fetch. */
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* @var resource The prepared SQL statement to execute.
|
||||
*/
|
||||
/** @var resource The prepared SQL statement to execute. */
|
||||
private $stmt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Prepares given statement for given connection.
|
||||
*
|
||||
* @param resource $conn The connection resource to use.
|
||||
@@ -101,14 +69,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function __construct($conn, $sql)
|
||||
{
|
||||
if ( ! is_resource($conn)) {
|
||||
if (! is_resource($conn)) {
|
||||
throw new SQLAnywhereException('Invalid SQL Anywhere connection resource: ' . $conn);
|
||||
}
|
||||
|
||||
$this->conn = $conn;
|
||||
$this->stmt = sasql_prepare($conn, $sql);
|
||||
|
||||
if ( ! is_resource($this->stmt)) {
|
||||
if (! is_resource($this->stmt)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($conn);
|
||||
}
|
||||
}
|
||||
@@ -140,7 +108,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
throw new SQLAnywhereException('Unknown type: ' . $type);
|
||||
}
|
||||
|
||||
if ( ! sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) {
|
||||
if (! sasql_stmt_bind_param_ex($this->stmt, $column - 1, $variable, $type, $variable === null)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
|
||||
}
|
||||
|
||||
@@ -162,7 +130,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
if (!sasql_stmt_reset($this->stmt)) {
|
||||
if (! sasql_stmt_reset($this->stmt)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
|
||||
}
|
||||
|
||||
@@ -204,13 +172,13 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
$hasZeroIndex = array_key_exists(0, $params);
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
$key = ($hasZeroIndex && is_numeric($key)) ? $key + 1 : $key;
|
||||
$key = $hasZeroIndex && is_numeric($key) ? $key + 1 : $key;
|
||||
|
||||
$this->bindValue($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! sasql_stmt_execute($this->stmt)) {
|
||||
if (! sasql_stmt_execute($this->stmt)) {
|
||||
throw SQLAnywhereException::fromSQLAnywhereError($this->conn, $this->stmt);
|
||||
}
|
||||
|
||||
@@ -224,9 +192,9 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*/
|
||||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
|
||||
{
|
||||
if ( ! is_resource($this->result)) {
|
||||
if (! is_resource($this->result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -254,7 +222,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
|
||||
$result = sasql_fetch_object($this->result);
|
||||
|
||||
if ($result instanceof \stdClass) {
|
||||
if ($result instanceof stdClass) {
|
||||
$result = $this->castObject($result, $className, $ctorArgs);
|
||||
}
|
||||
|
||||
@@ -280,7 +248,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
|
||||
switch ($fetchMode) {
|
||||
case FetchMode::CUSTOM_OBJECT:
|
||||
while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
|
||||
while ($row = $this->fetch(...func_get_args())) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
break;
|
||||
@@ -307,7 +275,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
{
|
||||
$row = $this->fetch(FetchMode::NUMERIC);
|
||||
|
||||
if (false === $row) {
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,29 +311,30 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
|
||||
/**
|
||||
* Casts a stdClass object to the given class name mapping its' properties.
|
||||
*
|
||||
* @param \stdClass $sourceObject Object to cast from.
|
||||
* @param stdClass $sourceObject Object to cast from.
|
||||
* @param string|object $destinationClass Name of the class or class instance to cast to.
|
||||
* @param array $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
* @param mixed[] $ctorArgs Arguments to use for constructing the destination class instance.
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @throws SQLAnywhereException
|
||||
*/
|
||||
private function castObject(\stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
|
||||
private function castObject(stdClass $sourceObject, $destinationClass, array $ctorArgs = [])
|
||||
{
|
||||
if ( ! is_string($destinationClass)) {
|
||||
if ( ! is_object($destinationClass)) {
|
||||
if (! is_string($destinationClass)) {
|
||||
if (! is_object($destinationClass)) {
|
||||
throw new SQLAnywhereException(sprintf(
|
||||
'Destination class has to be of type string or object, %s given.', gettype($destinationClass)
|
||||
'Destination class has to be of type string or object, %s given.',
|
||||
gettype($destinationClass)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$destinationClass = new \ReflectionClass($destinationClass);
|
||||
$destinationClass = new ReflectionClass($destinationClass);
|
||||
$destinationClass = $destinationClass->newInstanceArgs($ctorArgs);
|
||||
}
|
||||
|
||||
$sourceReflection = new \ReflectionObject($sourceObject);
|
||||
$destinationClassReflection = new \ReflectionObject($destinationClass);
|
||||
$sourceReflection = new ReflectionObject($sourceObject);
|
||||
$destinationClassReflection = new ReflectionObject($destinationClass);
|
||||
|
||||
foreach ($sourceReflection->getProperties() as $sourceProperty) {
|
||||
$sourceProperty->setAccessible(true);
|
||||
|
Reference in New Issue
Block a user