mirror of
https://github.com/dg/dibi.git
synced 2025-08-30 09:19:48 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1bae6eae08 | ||
|
34b7e22d40 | ||
|
369f5ee7d6 | ||
|
2d74bb3da0 | ||
|
a5422a65c9 | ||
|
5c806ea517 | ||
|
ecafed6246 | ||
|
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
|
||||
|
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
"dev-master": "3.2-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
// connects to SQlite using dibi class
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
date_default_timezone_set('Europe/Prague');
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../src/loader.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
dibi::connect([
|
||||
|
48
readme.md
48
readme.md
@@ -7,22 +7,28 @@
|
||||
[](https://github.com/dg/dibi/releases)
|
||||
[](https://github.com/dg/dibi/blob/master/license.md)
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Database access functions in PHP are not standardised. This library
|
||||
hides the differences between them, and above all, it gives you a very handy interface.
|
||||
|
||||
The best way to install Dibi is to use a [Composer](https://getcomposer.org/download):
|
||||
|
||||
php composer.phar require dibi/dibi
|
||||
Installation
|
||||
------------
|
||||
|
||||
Or you can download the latest package from https://dibiphp.com. In this
|
||||
package is also `Dibi.minified`, shrinked single-file version of whole Dibi,
|
||||
useful when you don't want to modify the library, but just use it.
|
||||
The recommended way to install Dibi is via Composer (alternatively you can [download package](https://github.com/dg/dibi/releases)):
|
||||
|
||||
Dibi requires PHP 5.4.4 or later. It has been tested with PHP 7 too.
|
||||
```bash
|
||||
composer require dibi/dibi
|
||||
```
|
||||
|
||||
The Dibi 3.x requires PHP version 5.4.4 and supports PHP up to 7.2.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
Usage
|
||||
-----
|
||||
|
||||
Refer to the `examples` directory for examples. Dibi documentation is
|
||||
available on the [homepage](https://dibiphp.com).
|
||||
@@ -30,34 +36,34 @@ available on the [homepage](https://dibiphp.com).
|
||||
Connect to database:
|
||||
|
||||
```php
|
||||
// connect to database (static way)
|
||||
dibi::connect([
|
||||
'driver' => 'mysql',
|
||||
$dibi = new Dibi\Connection([
|
||||
'driver' => 'mysqli',
|
||||
'host' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => '***',
|
||||
]);
|
||||
|
||||
// or object way; in all other examples use $connection-> instead of dibi::
|
||||
$connection = new DibiConnection($options);
|
||||
|
||||
// or static way; in all other examples use dibi:: instead of $dibi->
|
||||
dibi::connect($options);
|
||||
```
|
||||
|
||||
SELECT, INSERT, UPDATE
|
||||
|
||||
```php
|
||||
dibi::query('SELECT * FROM users WHERE id = ?', $id);
|
||||
$dibi->query('SELECT * FROM users WHERE id = ?', $id);
|
||||
|
||||
$arr = [
|
||||
'name' => 'John',
|
||||
'is_admin' => true,
|
||||
];
|
||||
dibi::query('INSERT INTO users', $arr);
|
||||
$dibi->query('INSERT INTO users', $arr);
|
||||
// INSERT INTO users (`name`, `is_admin`) VALUES ('John', 1)
|
||||
|
||||
dibi::query('UPDATE users SET', $arr, 'WHERE `id`=?', $x);
|
||||
$dibi->query('UPDATE users SET', $arr, 'WHERE `id`=?', $x);
|
||||
// UPDATE users SET `name`='John', `is_admin`=1 WHERE `id` = 123
|
||||
|
||||
dibi::query('UPDATE users SET', [
|
||||
$dibi->query('UPDATE users SET', [
|
||||
'title' => array('SHA1(?)', 'tajneheslo'),
|
||||
]);
|
||||
// UPDATE users SET 'title' = SHA1('tajneheslo')
|
||||
@@ -66,7 +72,7 @@ dibi::query('UPDATE users SET', [
|
||||
Getting results
|
||||
|
||||
```php
|
||||
$result = dibi::query('SELECT * FROM users');
|
||||
$result = $dibi->query('SELECT * FROM users');
|
||||
|
||||
$value = $result->fetchSingle(); // single value
|
||||
$all = $result->fetchAll(); // all rows
|
||||
@@ -82,7 +88,7 @@ foreach ($result as $n => $row) {
|
||||
Modifiers for arrays:
|
||||
|
||||
```php
|
||||
dibi::query('SELECT * FROM users WHERE %and', [
|
||||
$dibi->query('SELECT * FROM users WHERE %and', [
|
||||
array('number > ?', 10),
|
||||
array('number < ?', 100),
|
||||
]);
|
||||
@@ -105,7 +111,7 @@ dibi::query('SELECT * FROM users WHERE %and', [
|
||||
Modifiers for LIKE
|
||||
|
||||
```php
|
||||
dibi::query("SELECT * FROM table WHERE name LIKE %like~", $query);
|
||||
$dibi->query("SELECT * FROM table WHERE name LIKE %like~", $query);
|
||||
```
|
||||
|
||||
<table>
|
||||
@@ -117,7 +123,7 @@ dibi::query("SELECT * FROM table WHERE name LIKE %like~", $query);
|
||||
DateTime:
|
||||
|
||||
```php
|
||||
dibi::query('UPDATE users SET', [
|
||||
$dibi->query('UPDATE users SET', [
|
||||
'time' => new DateTime,
|
||||
]);
|
||||
// UPDATE users SET ('2008-01-01 01:08:10')
|
||||
|
@@ -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.2.0',
|
||||
REVISION = 'released on 2018-03-09';
|
||||
|
||||
/** sorting order */
|
||||
const
|
||||
@@ -64,7 +64,7 @@ class dibi
|
||||
/** @var string Default dibi driver */
|
||||
public static $defaultDriver = 'mysqli';
|
||||
|
||||
/** @var Dibi\Connection[] Connection registry storage for DibiConnection objects */
|
||||
/** @var Dibi\Connection[] Connection registry storage for Dibi\Connection objects */
|
||||
private static $registry = [];
|
||||
|
||||
/** @var Dibi\Connection Current connection */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -12,59 +12,7 @@ if (PHP_VERSION_ID < 50404) {
|
||||
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
static $map = [
|
||||
'dibi' => 'dibi.php',
|
||||
'Dibi\Bridges\Nette\DibiExtension22' => 'Bridges/Nette/DibiExtension22.php',
|
||||
'Dibi\Bridges\Tracy\Panel' => 'Bridges/Tracy/Panel.php',
|
||||
'Dibi\Connection' => 'Connection.php',
|
||||
'Dibi\DataSource' => 'DataSource.php',
|
||||
'Dibi\DateTime' => 'DateTime.php',
|
||||
'Dibi\Driver' => 'interfaces.php',
|
||||
'Dibi\DriverException' => 'exceptions.php',
|
||||
'Dibi\Drivers\FirebirdDriver' => 'Drivers/FirebirdDriver.php',
|
||||
'Dibi\Drivers\SqlsrvDriver' => 'Drivers/SqlsrvDriver.php',
|
||||
'Dibi\Drivers\SqlsrvReflector' => 'Drivers/SqlsrvReflector.php',
|
||||
'Dibi\Drivers\MsSqlDriver' => 'Drivers/MsSqlDriver.php',
|
||||
'Dibi\Drivers\MsSqlReflector' => 'Drivers/MsSqlReflector.php',
|
||||
'Dibi\Drivers\MySqlDriver' => 'Drivers/MySqlDriver.php',
|
||||
'Dibi\Drivers\MySqliDriver' => 'Drivers/MySqliDriver.php',
|
||||
'Dibi\Drivers\MySqlReflector' => 'Drivers/MySqlReflector.php',
|
||||
'Dibi\Drivers\OdbcDriver' => 'Drivers/OdbcDriver.php',
|
||||
'Dibi\Drivers\OracleDriver' => 'Drivers/OracleDriver.php',
|
||||
'Dibi\Drivers\PdoDriver' => 'Drivers/PdoDriver.php',
|
||||
'Dibi\Drivers\PostgreDriver' => 'Drivers/PostgreDriver.php',
|
||||
'Dibi\Drivers\Sqlite3Driver' => 'Drivers/Sqlite3Driver.php',
|
||||
'Dibi\Drivers\SqliteReflector' => 'Drivers/SqliteReflector.php',
|
||||
'Dibi\Event' => 'Event.php',
|
||||
'Dibi\Exception' => 'exceptions.php',
|
||||
'Dibi\Fluent' => 'Fluent.php',
|
||||
'Dibi\HashMap' => 'HashMap.php',
|
||||
'Dibi\HashMapBase' => 'HashMap.php',
|
||||
'Dibi\Helpers' => 'Helpers.php',
|
||||
'Dibi\IDataSource' => 'interfaces.php',
|
||||
'Dibi\Literal' => 'Literal.php',
|
||||
'Dibi\Loggers\FileLogger' => 'Loggers/FileLogger.php',
|
||||
'Dibi\Loggers\FirePhpLogger' => 'Loggers/FirePhpLogger.php',
|
||||
'Dibi\NotImplementedException' => 'exceptions.php',
|
||||
'Dibi\NotSupportedException' => 'exceptions.php',
|
||||
'Dibi\PcreException' => 'exceptions.php',
|
||||
'Dibi\ProcedureException' => 'exceptions.php',
|
||||
'Dibi\Reflection\Column' => 'Reflection/Column.php',
|
||||
'Dibi\Reflection\Database' => 'Reflection/Database.php',
|
||||
'Dibi\Reflection\ForeignKey' => 'Reflection/ForeignKey.php',
|
||||
'Dibi\Reflection\Index' => 'Reflection/Index.php',
|
||||
'Dibi\Reflection\Result' => 'Reflection/Result.php',
|
||||
'Dibi\Reflection\Table' => 'Reflection/Table.php',
|
||||
'Dibi\Reflector' => 'interfaces.php',
|
||||
'Dibi\Result' => 'Result.php',
|
||||
'Dibi\ResultDriver' => 'interfaces.php',
|
||||
'Dibi\ResultIterator' => 'ResultIterator.php',
|
||||
'Dibi\Row' => 'Row.php',
|
||||
'Dibi\Strict' => 'Strict.php',
|
||||
'Dibi\Translator' => 'Translator.php',
|
||||
'Dibi\Type' => 'Type.php',
|
||||
], $old2new = [
|
||||
'Dibi' => 'dibi.php',
|
||||
$old2new = [
|
||||
'DibiColumnInfo' => 'Dibi\Reflection\Column',
|
||||
'DibiConnection' => 'Dibi\Connection',
|
||||
'DibiDatabaseInfo' => 'Dibi\Reflection\Database',
|
||||
@@ -112,29 +60,10 @@ spl_autoload_register(function ($class) {
|
||||
'Dibi\Drivers\MsSql2005Driver' => 'Dibi\Drivers\SqlsrvDriver',
|
||||
'Dibi\Drivers\MsSql2005Reflector' => 'Dibi\Drivers\SqlsrvReflector',
|
||||
];
|
||||
if (isset($map[$class])) {
|
||||
require __DIR__ . '/Dibi/' . $map[$class];
|
||||
} elseif (isset($old2new[$class])) {
|
||||
if (isset($old2new[$class])) {
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
$location = isset($trace[1]['file']) ? 'used in ' . $trace[1]['file'] . ':' . $trace[1]['line'] : '';
|
||||
trigger_error("Class $class $location has been renamed to {$old2new[$class]}.", E_USER_DEPRECATED);
|
||||
class_alias($old2new[$class], $class);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// preload for compatiblity
|
||||
array_map('class_exists', [
|
||||
'DibiConnection',
|
||||
'DibiDateTime',
|
||||
'DibiDriverException',
|
||||
'DibiEvent',
|
||||
'DibiException',
|
||||
'DibiFluent',
|
||||
'DibiLiteral',
|
||||
'DibiNotImplementedException',
|
||||
'DibiNotSupportedException',
|
||||
'DibiPcreException',
|
||||
'DibiProcedureException',
|
||||
'DibiResult',
|
||||
'DibiRow',
|
||||
'IDataSource',
|
||||
'IDibiDriver',
|
||||
]);
|
||||
|
@@ -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', [
|
||||
|
@@ -40,9 +40,6 @@ if ($config['driver'] === 'mysql' && PHP_VERSION_ID >= 70000) {
|
||||
}
|
||||
|
||||
|
||||
$conn = new Dibi\Connection($config);
|
||||
|
||||
|
||||
function test(Closure $function)
|
||||
{
|
||||
$function();
|
||||
|
Reference in New Issue
Block a user