mirror of
https://github.com/dg/dibi.git
synced 2025-09-01 18:12:51 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
504b7725c7 | ||
|
822405b478 | ||
|
43d3b57a8d | ||
|
4f0566ece7 | ||
|
67521084d9 | ||
|
22ac601502 | ||
|
b740b70f18 | ||
|
44fc3f4553 |
@@ -20,8 +20,8 @@ install:
|
||||
- IF EXIST c:\php5 (SET PHP=0) ELSE (SET PHP=1)
|
||||
- IF %PHP%==1 mkdir c:\php5
|
||||
- IF %PHP%==1 cd c:\php5
|
||||
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.6.14-Win32-VC11-x86.zip
|
||||
- IF %PHP%==1 7z x php-5.6.14-Win32-VC11-x86.zip >nul
|
||||
- IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-5.6.14-Win32-VC11-x86.zip --output php.zip
|
||||
- IF %PHP%==1 7z x php.zip >nul
|
||||
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
||||
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
|
||||
- IF %PHP%==1 appveyor DownloadFile https://files.nette.org/misc/php-sqlsrv.zip
|
||||
@@ -34,8 +34,8 @@ install:
|
||||
- IF EXIST c:\php7 (SET PHP=0) ELSE (SET PHP=1)
|
||||
- IF %PHP%==1 mkdir c:\php7
|
||||
- IF %PHP%==1 cd c:\php7
|
||||
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.3-Win32-VC14-x86.zip
|
||||
- IF %PHP%==1 7z x php-7.0.3-Win32-VC14-x86.zip >nul
|
||||
- IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.0.3-Win32-VC14-x86.zip --output php.zip
|
||||
- IF %PHP%==1 7z x php.zip >nul
|
||||
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
||||
- IF %PHP%==1 appveyor DownloadFile https://files.nette.org/misc/php-sqlsrv.zip
|
||||
- IF %PHP%==1 7z x php-sqlsrv.zip >nul
|
||||
|
@@ -263,7 +263,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||
$value = new Dibi\DateTime($value);
|
||||
}
|
||||
return $value->format("'Y-m-d H:i:s.u'");
|
||||
return 'CONVERT(DATETIME2(7), ' . $value->format("'Y-m-d H:i:s.u'") . ')';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -33,7 +33,9 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
use Dibi\Strict;
|
||||
|
||||
const ERROR_ACCESS_DENIED = 1045;
|
||||
|
||||
const ERROR_DUPLICATE_ENTRY = 1062;
|
||||
|
||||
const ERROR_DATA_TRUNCATED = 1265;
|
||||
|
||||
/** @var resource|null */
|
||||
|
@@ -34,7 +34,9 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
use Dibi\Strict;
|
||||
|
||||
const ERROR_ACCESS_DENIED = 1045;
|
||||
|
||||
const ERROR_DUPLICATE_ENTRY = 1062;
|
||||
|
||||
const ERROR_DATA_TRUNCATED = 1265;
|
||||
|
||||
/** @var \mysqli|null */
|
||||
@@ -148,7 +150,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
$res = @mysqli_query($this->connection, $sql, $this->buffered ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); // intentionally @
|
||||
|
||||
if ($code = mysqli_errno($this->connection)) {
|
||||
throw self::createException(mysqli_error($this->connection), $code, $sql);
|
||||
throw static::createException(mysqli_error($this->connection), $code, $sql);
|
||||
|
||||
} elseif (is_object($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
|
@@ -42,6 +42,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
|
||||
/** @var string Date and datetime format */
|
||||
private $fmtDate;
|
||||
|
||||
private $fmtDateTime;
|
||||
|
||||
/** @var int|false Number of affected rows */
|
||||
@@ -119,7 +120,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
@oci_execute($res, $this->autocommit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT);
|
||||
$err = oci_error($res);
|
||||
if ($err) {
|
||||
throw self::createException($err['message'], $err['code'], $sql);
|
||||
throw static::createException($err['message'], $err['code'], $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = oci_num_rows($res);
|
||||
|
@@ -348,7 +348,15 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||
$value = new Dibi\DateTime($value);
|
||||
}
|
||||
return $value->format($this->driverName === 'odbc' ? '#m/d/Y H:i:s.u#' : "'Y-m-d H:i:s.u'");
|
||||
switch ($this->driverName) {
|
||||
case 'odbc':
|
||||
return $value->format('#m/d/Y H:i:s.u#');
|
||||
case 'mssql':
|
||||
case 'sqlsrv':
|
||||
return 'CONVERT(DATETIME2(7), ' . $value->format("'Y-m-d H:i:s.u'") . ')';
|
||||
default:
|
||||
return $value->format("'Y-m-d H:i:s.u'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -96,7 +96,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
pg_set_error_verbosity($this->connection, PGSQL_ERRORS_VERBOSE);
|
||||
|
||||
if (isset($config['charset']) && pg_set_client_encoding($this->connection, $config['charset'])) {
|
||||
throw self::createException(pg_last_error($this->connection));
|
||||
throw static::createException(pg_last_error($this->connection));
|
||||
}
|
||||
|
||||
if (isset($config['schema'])) {
|
||||
@@ -137,7 +137,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
$res = @pg_query($this->connection, $sql); // intentionally @
|
||||
|
||||
if ($res === false) {
|
||||
throw self::createException(pg_last_error($this->connection), null, $sql);
|
||||
throw static::createException(pg_last_error($this->connection), null, $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = pg_affected_rows($res);
|
||||
|
@@ -38,10 +38,12 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
||||
|
||||
/** @var string Date and datetime format */
|
||||
private $fmtDate;
|
||||
|
||||
private $fmtDateTime;
|
||||
|
||||
/** @var string character encoding */
|
||||
private $dbcharset;
|
||||
|
||||
private $charset;
|
||||
|
||||
|
||||
@@ -115,7 +117,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
||||
|
||||
$res = @$this->connection->query($sql); // intentionally @
|
||||
if ($code = $this->connection->lastErrorCode()) {
|
||||
throw self::createException($this->connection->lastErrorMsg(), $code, $sql);
|
||||
throw static::createException($this->connection->lastErrorMsg(), $code, $sql);
|
||||
|
||||
} elseif ($res instanceof \SQLite3Result && $res->numColumns()) {
|
||||
return $this->createResultDriver($res);
|
||||
|
@@ -8,7 +8,6 @@
|
||||
namespace Dibi\Drivers;
|
||||
|
||||
use Dibi;
|
||||
use Dibi\Connection;
|
||||
use Dibi\Helpers;
|
||||
|
||||
|
||||
@@ -287,7 +286,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||
$value = new Dibi\DateTime($value);
|
||||
}
|
||||
return $value->format("'Y-m-d H:i:s.u'");
|
||||
return 'CONVERT(DATETIME2(7), ' . $value->format("'Y-m-d H:i:s.u'") . ')';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -8,7 +8,6 @@
|
||||
namespace Dibi\Reflection;
|
||||
|
||||
use Dibi;
|
||||
use Dibi\Type;
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -22,8 +22,8 @@ class dibi
|
||||
|
||||
/** version */
|
||||
const
|
||||
VERSION = '3.1.0',
|
||||
REVISION = 'released on 2017-09-25';
|
||||
VERSION = '3.1.1',
|
||||
REVISION = 'released on 2018-03-09';
|
||||
|
||||
/** sorting order */
|
||||
const
|
||||
|
@@ -22,10 +22,11 @@ class Exception extends \Exception
|
||||
* @param string Message describing the exception
|
||||
* @param mixed
|
||||
* @param string SQL command
|
||||
* @param \Exception
|
||||
*/
|
||||
public function __construct($message = '', $code = 0, $sql = null)
|
||||
public function __construct($message = '', $code = 0, $sql = null, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message);
|
||||
parent::__construct($message, 0, $previous);
|
||||
$this->code = $code;
|
||||
$this->sql = $sql;
|
||||
}
|
||||
|
@@ -64,7 +64,6 @@ spl_autoload_register(function ($class) {
|
||||
'Dibi\Translator' => 'Translator.php',
|
||||
'Dibi\Type' => 'Type.php',
|
||||
], $old2new = [
|
||||
'Dibi' => 'dibi.php',
|
||||
'DibiColumnInfo' => 'Dibi\Reflection\Column',
|
||||
'DibiConnection' => 'Dibi\Connection',
|
||||
'DibiDatabaseInfo' => 'Dibi\Reflection\Database',
|
||||
|
@@ -181,6 +181,8 @@ if ($config['system'] === 'odbc') {
|
||||
Assert::same(
|
||||
reformat([
|
||||
'odbc' => 'INSERT INTO test ([a2], [a4], [b1], [b2], [b3], [b4], [b5], [b6], [b7], [b8], [b9], [c1]) VALUES (#09/26/1212 00:00:00.000000#, #12/31/1969 22:13:20.000000#, #09/26/1212#, #09/26/1212 00:00:00.000000#, #12/31/1969#, #12/31/1969 22:13:20.000000#, #09/26/1212 00:00:00.000000#, #09/26/1212#, #09/26/1212 00:00:00.000000#, NULL, NULL, #09/26/1212 16:51:34.012400#)',
|
||||
'mssql' => "INSERT INTO test ([a2], [a4], [b1], [b2], [b3], [b4], [b5], [b6], [b7], [b8], [b9], [c1]) VALUES (CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), CONVERT(DATETIME2(7), '1969-12-31 22:13:20.000000'), '1212-09-26', CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), '1969-12-31', CONVERT(DATETIME2(7), '1969-12-31 22:13:20.000000'), CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), '1212-09-26', CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), NULL, NULL, CONVERT(DATETIME2(7), '1212-09-26 16:51:34.012400'))",
|
||||
'sqlsrv' => "INSERT INTO test ([a2], [a4], [b1], [b2], [b3], [b4], [b5], [b6], [b7], [b8], [b9], [c1]) VALUES (CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), CONVERT(DATETIME2(7), '1969-12-31 22:13:20.000000'), '1212-09-26', CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), '1969-12-31', CONVERT(DATETIME2(7), '1969-12-31 22:13:20.000000'), CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), '1212-09-26', CONVERT(DATETIME2(7), '1212-09-26 00:00:00.000000'), NULL, NULL, CONVERT(DATETIME2(7), '1212-09-26 16:51:34.012400'))",
|
||||
"INSERT INTO test ([a2], [a4], [b1], [b2], [b3], [b4], [b5], [b6], [b7], [b8], [b9], [c1]) VALUES ('1212-09-26 00:00:00.000000', '1969-12-31 22:13:20.000000', '1212-09-26', '1212-09-26 00:00:00.000000', '1969-12-31', '1969-12-31 22:13:20.000000', '1212-09-26 00:00:00.000000', '1212-09-26', '1212-09-26 00:00:00.000000', NULL, NULL, '1212-09-26 16:51:34.012400')",
|
||||
]),
|
||||
$conn->translate('INSERT INTO test', [
|
||||
|
Reference in New Issue
Block a user