1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-18 03:41:30 +02:00

strict type fixes

This commit is contained in:
David Grudl
2017-06-09 22:58:05 +02:00
parent f9997f9b52
commit 957d9281f3
5 changed files with 9 additions and 10 deletions

View File

@@ -106,7 +106,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
} }
} }
} }
@mysqli_real_connect($this->connection, (empty($config['persistent']) ? '' : 'p:') . $config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket'], $config['flags']); // intentionally @ @mysqli_real_connect($this->connection, (empty($config['persistent']) ? '' : 'p:') . $config['host'], $config['username'], $config['password'], $config['database'] ?? '', $config['port'] ?? 0, $config['socket'], $config['flags'] ?? 0); // intentionally @
if ($errno = mysqli_connect_errno()) { if ($errno = mysqli_connect_errno()) {
throw new Dibi\DriverException(mysqli_connect_error(), $errno); throw new Dibi\DriverException(mysqli_connect_error(), $errno);

View File

@@ -69,9 +69,9 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
]; ];
if (empty($config['persistent'])) { if (empty($config['persistent'])) {
$this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']); // intentionally @ $this->connection = @odbc_connect($config['dsn'], $config['username'] ?? '', $config['password'] ?? ''); // intentionally @
} else { } else {
$this->connection = @odbc_pconnect($config['dsn'], $config['username'], $config['password']); // intentionally @ $this->connection = @odbc_pconnect($config['dsn'], $config['username'] ?? '', $config['password'] ?? ''); // intentionally @
} }
} }
@@ -134,7 +134,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
*/ */
public function begin(string $savepoint = NULL): void public function begin(string $savepoint = NULL): void
{ {
if (!odbc_autocommit($this->connection, FALSE)) { if (!odbc_autocommit($this->connection, 0/*FALSE*/)) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection)); throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
} }
} }
@@ -149,7 +149,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
if (!odbc_commit($this->connection)) { if (!odbc_commit($this->connection)) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection)); throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
} }
odbc_autocommit($this->connection, TRUE); odbc_autocommit($this->connection, 1/*TRUE*/);
} }
@@ -162,7 +162,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
if (!odbc_rollback($this->connection)) { if (!odbc_rollback($this->connection)) {
throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection)); throw new Dibi\DriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection));
} }
odbc_autocommit($this->connection, TRUE); odbc_autocommit($this->connection, 1/*TRUE*/);
} }

View File

@@ -80,8 +80,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
} }
$this->driverName = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); $this->driverName = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME);
$this->serverVersion = $config['version'] $this->serverVersion = (string) ($config['version'] ?? @$this->connection->getAttribute(PDO::ATTR_SERVER_VERSION)); // @ - may be not supported
?? @$this->connection->getAttribute(PDO::ATTR_SERVER_VERSION); // @ - may be not supported
} }

View File

@@ -137,7 +137,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
$res = sqlsrv_query($this->connection, 'SELECT SCOPE_IDENTITY()'); $res = sqlsrv_query($this->connection, 'SELECT SCOPE_IDENTITY()');
if (is_resource($res)) { if (is_resource($res)) {
$row = sqlsrv_fetch_array($res, SQLSRV_FETCH_NUMERIC); $row = sqlsrv_fetch_array($res, SQLSRV_FETCH_NUMERIC);
return $row[0]; return (int) $row[0];
} }
return NULL; return NULL;
} }

View File

@@ -70,7 +70,7 @@ function reformat($s)
function num($n) function num($n)
{ {
global $config; global $config;
if (substr(@$config['dsn'], 0, 5) === 'odbc:' || $config['driver'] === 'sqlite') { if (substr($config['dsn'] ?? '', 0, 5) === 'odbc:' || $config['driver'] === 'sqlite') {
$n = is_float($n) ? "$n.0" : (string) $n; $n = is_float($n) ? "$n.0" : (string) $n;
} }
return $n; return $n;