mirror of
https://github.com/dg/dibi.git
synced 2025-09-06 04:12:53 +02:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4e838fc2b5 | ||
|
37487816db | ||
|
0c099bb2bc | ||
|
1786c861b9 | ||
|
bc0578928f | ||
|
12a07ff6ad | ||
|
b50f59c64c | ||
|
fdebf349f5 | ||
|
954c2f25d0 | ||
|
43dccb1ba2 | ||
|
352a683ec1 | ||
|
f4638796fb | ||
|
4659f4550e | ||
|
c3548465fb | ||
|
dda0bdbd67 | ||
|
7142be254b | ||
|
3b00115ee5 |
30
appveyor.yml
30
appveyor.yml
@@ -1,6 +1,7 @@
|
||||
build: off
|
||||
cache:
|
||||
- c:\php -> appveyor.yml
|
||||
- c:\php5 -> appveyor.yml
|
||||
- c:\php7 -> appveyor.yml
|
||||
- '%LOCALAPPDATA%\Composer\files -> appveyor.yml'
|
||||
|
||||
clone_folder: c:\projects\dibi
|
||||
@@ -11,14 +12,14 @@ services:
|
||||
- mysql
|
||||
|
||||
init:
|
||||
- SET PATH=c:\php;%PATH%
|
||||
- SET PHP=1
|
||||
- SET PATH=c:\php5;%PATH%
|
||||
- SET ANSICON=121x90 (121x90)
|
||||
|
||||
install:
|
||||
# Install PHP
|
||||
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
|
||||
- IF %PHP%==1 cd c:\php
|
||||
# Install PHP 5
|
||||
- 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 echo extension_dir=ext >> php.ini
|
||||
@@ -28,9 +29,21 @@ install:
|
||||
- IF %PHP%==1 copy SQLSRV\php_sqlsrv_56_ts.dll ext\php_sqlsrv_ts.dll
|
||||
- IF %PHP%==1 copy SQLSRV\php_pdo_sqlsrv_56_ts.dll ext\php_pdo_sqlsrv_ts.dll
|
||||
- IF %PHP%==1 del /Q *.zip
|
||||
- cd c:\projects\dibi
|
||||
|
||||
# Install PHP 7
|
||||
- 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 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
|
||||
- IF %PHP%==1 copy SQLSRV\php_sqlsrv_7_ts.dll ext\php_sqlsrv_ts.dll
|
||||
- IF %PHP%==1 del /Q *.zip
|
||||
|
||||
# Install Nette Tester
|
||||
- cd c:\projects\dibi
|
||||
- appveyor DownloadFile https://getcomposer.org/composer.phar
|
||||
- php composer.phar install --prefer-dist --no-interaction --no-progress
|
||||
|
||||
@@ -38,7 +51,8 @@ install:
|
||||
- copy tests\databases.appveyor.ini tests\databases.ini
|
||||
|
||||
test_script:
|
||||
- vendor\bin\tester tests -s -p php -c tests\php-win.ini
|
||||
- vendor\bin\tester tests -s -p c:\php5\php -c tests\php5-win.ini
|
||||
- vendor\bin\tester tests -s -p c:\php7\php -c tests\php7-win.ini
|
||||
|
||||
on_failure:
|
||||
# Print *.actual content
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
namespace Dibi\Bridges\Nette;
|
||||
|
||||
use Dibi;
|
||||
use Nette;
|
||||
|
||||
|
||||
@@ -47,7 +48,10 @@ class DibiExtension22 extends Nette\DI\CompilerExtension
|
||||
}
|
||||
if ($useProfiler) {
|
||||
$panel = $container->addDefinition($this->prefix('panel'))
|
||||
->setClass('Dibi\Bridges\Tracy\Panel');
|
||||
->setClass('Dibi\Bridges\Tracy\Panel', [
|
||||
isset($config['explain']) ? $config['explain'] : TRUE,
|
||||
isset($config['filter']) && $config['filter'] === FALSE ? Dibi\Event::ALL : Dibi\Event::QUERY,
|
||||
]);
|
||||
$connection->addSetup([$panel, 'register'], [$connection]);
|
||||
}
|
||||
}
|
||||
|
@@ -268,7 +268,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
|
||||
public function escapeIdentifier($value)
|
||||
{
|
||||
return $value;
|
||||
return '"' . str_replace('"', '""', $value). '"';
|
||||
}
|
||||
|
||||
|
||||
|
@@ -72,12 +72,17 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
$this->connection = $config['resource'];
|
||||
|
||||
} else {
|
||||
// Default values
|
||||
if (!isset($config['options']['CharacterSet'])) {
|
||||
$config['options']['CharacterSet'] = 'UTF-8';
|
||||
}
|
||||
$options = $config['options'];
|
||||
|
||||
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
||||
// Default values
|
||||
if (!isset($options['CharacterSet'])) {
|
||||
$options['CharacterSet'] = 'UTF-8';
|
||||
}
|
||||
$options['PWD'] = (string) $options['PWD'];
|
||||
$options['UID'] = (string) $options['UID'];
|
||||
$options['Database'] = (string) $options['Database'];
|
||||
|
||||
$this->connection = sqlsrv_connect($config['host'], $options);
|
||||
}
|
||||
|
||||
if (!is_resource($this->connection)) {
|
||||
@@ -136,7 +141,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function getInsertId($sequence)
|
||||
{
|
||||
$res = sqlsrv_query($this->connection, 'SELECT @@IDENTITY');
|
||||
$res = sqlsrv_query($this->connection, 'SELECT SCOPE_IDENTITY()');
|
||||
if (is_resource($res)) {
|
||||
$row = sqlsrv_fetch_array($res, SQLSRV_FETCH_NUMERIC);
|
||||
return $row[0];
|
||||
|
@@ -25,6 +25,7 @@ namespace Dibi;
|
||||
* @method Fluent innerJoin(...$table)
|
||||
* @method Fluent rightJoin(...$table)
|
||||
* @method Fluent outerJoin(...$table)
|
||||
* @method Fluent as(...$field)
|
||||
* @method Fluent on(...$cond)
|
||||
* @method Fluent using(...$cond)
|
||||
*/
|
||||
|
@@ -183,7 +183,7 @@ class Helpers
|
||||
static $patterns = [
|
||||
'^_' => Type::TEXT, // PostgreSQL arrays
|
||||
'BYTEA|BLOB|BIN' => Type::BINARY,
|
||||
'TEXT|CHAR|POINT|INTERVAL' => Type::TEXT,
|
||||
'TEXT|CHAR|POINT|INTERVAL|STRING' => Type::TEXT,
|
||||
'YEAR|BYTE|COUNTER|SERIAL|INT|LONG|SHORT|^TINY$' => Type::INTEGER,
|
||||
'CURRENCY|REAL|MONEY|FLOAT|DOUBLE|DECIMAL|NUMERIC|NUMBER' => Type::FLOAT,
|
||||
'^TIME$' => Type::TIME,
|
||||
|
@@ -22,8 +22,8 @@ class dibi
|
||||
|
||||
/** version */
|
||||
const
|
||||
VERSION = '3.0.2',
|
||||
REVISION = 'released on 2016-01-29';
|
||||
VERSION = '3.0.4',
|
||||
REVISION = 'released on 2016-04-06';
|
||||
|
||||
/** sorting order */
|
||||
const
|
||||
|
@@ -13,8 +13,6 @@ namespace Dibi;
|
||||
*/
|
||||
class Exception extends \Exception
|
||||
{
|
||||
use Strict;
|
||||
|
||||
/** @var string|NULL */
|
||||
private $sql;
|
||||
|
||||
@@ -66,7 +64,6 @@ class DriverException extends Exception
|
||||
*/
|
||||
class PcreException extends Exception
|
||||
{
|
||||
use Strict;
|
||||
|
||||
public function __construct($message = '%msg.')
|
||||
{
|
||||
|
28
tests/dibi/Sqlsrv.insert.phpt
Normal file
28
tests/dibi/Sqlsrv.insert.phpt
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @dataProvider? ../databases.ini sqlsrv
|
||||
*/
|
||||
|
||||
use Tester\Assert;
|
||||
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
$conn = new Dibi\Connection($config);
|
||||
$conn->loadFile(__DIR__ . "/data/sqlsrv.insert.sql");
|
||||
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$conn->query('INSERT INTO %n DEFAULT VALUES', 'aaa');
|
||||
Assert::equal($i, $conn->getInsertId());
|
||||
}
|
||||
|
||||
$conn->query('INSERT INTO %n DEFAULT VALUES', 'aab');
|
||||
Assert::equal(1, $conn->getInsertId());
|
||||
|
||||
$conn->query(
|
||||
'CREATE TRIGGER %n ON %n AFTER INSERT AS INSERT INTO %n DEFAULT VALUES',
|
||||
'UpdAAB', 'aab', 'aaa'
|
||||
);
|
||||
|
||||
$conn->query('INSERT INTO %n DEFAULT VALUES', 'aab');
|
||||
Assert::equal(2, $conn->getInsertId());
|
5
tests/dibi/data/sqlsrv.insert.sql
Normal file
5
tests/dibi/data/sqlsrv.insert.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
IF OBJECT_ID('aaa', 'U') IS NOT NULL DROP TABLE aaa;
|
||||
IF OBJECT_ID('aab', 'U') IS NOT NULL DROP TABLE aab;
|
||||
|
||||
CREATE TABLE aaa ( [id] int NOT NULL IDENTITY PRIMARY KEY )
|
||||
CREATE TABLE aab ( [id] int NOT NULL IDENTITY PRIMARY KEY )
|
17
tests/php7-win.ini
Normal file
17
tests/php7-win.ini
Normal file
@@ -0,0 +1,17 @@
|
||||
[PHP]
|
||||
extension_dir = "./ext"
|
||||
;extension=php_mssql.dll
|
||||
extension=php_mysqli.dll
|
||||
;extension=php_oci8.dll
|
||||
;extension=php_oci8_11g.dll
|
||||
;extension=php_pdo_firebird.dll
|
||||
;extension=php_pdo_mssql.dll
|
||||
extension=php_pdo_mysql.dll
|
||||
;extension=php_pdo_oci.dll
|
||||
extension=php_pdo_odbc.dll
|
||||
extension=php_pdo_pgsql.dll
|
||||
extension=php_pdo_sqlite.dll
|
||||
extension=php_pgsql.dll
|
||||
extension=php_sqlite3.dll
|
||||
extension=php_sqlsrv_ts.dll
|
||||
extension=php_odbc.dll
|
Reference in New Issue
Block a user