mirror of
https://github.com/dg/dibi.git
synced 2025-08-30 09:19:48 +02:00
Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9b070bb737 | ||
|
917971992f | ||
|
bc564555f8 | ||
|
3e20a6b8fc | ||
|
c019e7cac2 | ||
|
2294c195f4 | ||
|
25246529f7 | ||
|
d405ec369b | ||
|
b7974fe192 | ||
|
80f1898e1b | ||
|
8e8e6dfdca | ||
|
6510fcce25 | ||
|
b7d84b90ef | ||
|
2571e54f3c | ||
|
15e6d9f738 | ||
|
ddfd4a0f1a | ||
|
4e838fc2b5 | ||
|
37487816db | ||
|
0c099bb2bc | ||
|
1786c861b9 | ||
|
bc0578928f | ||
|
12a07ff6ad | ||
|
b50f59c64c | ||
|
fdebf349f5 | ||
|
954c2f25d0 | ||
|
43dccb1ba2 | ||
|
352a683ec1 | ||
|
f4638796fb | ||
|
4659f4550e | ||
|
c3548465fb | ||
|
dda0bdbd67 | ||
|
7142be254b | ||
|
3b00115ee5 |
13
.travis.yml
13
.travis.yml
@@ -4,14 +4,16 @@ php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: 7.1
|
||||
- php: hhvm
|
||||
|
||||
script:
|
||||
- vendor/bin/tester tests -s -p php -c tests/php-unix.ini
|
||||
- vendor/bin/tester tests -s -p php -c tests/php-unix.ini $COVERAGE
|
||||
- php temp/code-checker/src/code-checker.php --short-arrays
|
||||
|
||||
after_failure:
|
||||
@@ -22,6 +24,7 @@ before_script:
|
||||
# Install Nette Tester & Code Checker
|
||||
- travis_retry composer install --no-interaction
|
||||
- travis_retry composer create-project nette/code-checker temp/code-checker ~2.5 --no-interaction
|
||||
- if [ $TRAVIS_PHP_VERSION == "7.0" ]; then COVERAGE="-p phpdbg --coverage ./coverage.xml --coverage-src ./src"; fi
|
||||
|
||||
# Create databases.ini
|
||||
- cp ./tests/databases.travis.ini ./tests/databases.ini
|
||||
@@ -29,6 +32,14 @@ before_script:
|
||||
# Create Postgre database
|
||||
- psql -c 'CREATE DATABASE dibi_test' -U postgres
|
||||
|
||||
after_script:
|
||||
# Report Code Coverage
|
||||
- >
|
||||
if [ "$COVERAGE" != "" ]; then
|
||||
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
|
||||
&& php coveralls.phar --verbose --config tests/.coveralls.yml
|
||||
|| true; fi
|
||||
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
|
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
|
||||
|
@@ -15,10 +15,10 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"tracy/tracy": "~2.2",
|
||||
"nette/tester": "~1.3"
|
||||
"nette/tester": "~1.7"
|
||||
},
|
||||
"replace": {
|
||||
"dg/dibi": "self.version"
|
||||
"dg/dibi": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["src/"],
|
||||
|
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ class Panel implements Tracy\IBarPanel
|
||||
$backup = [$event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
|
||||
$event->connection->onEvent = NULL;
|
||||
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
|
||||
$explain = Helpers::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
|
||||
$explain = Helpers::dump(@$event->connection->nativeQuery("$cmd $event->sql"), TRUE);
|
||||
} catch (Dibi\Exception $e) {
|
||||
}
|
||||
list($event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
|
||||
|
@@ -55,4 +55,18 @@ class DateTime extends \DateTime
|
||||
return $this->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
if (isset($this->fix, $this->fix[1])) {
|
||||
$this->__construct($this->fix[0], new \DateTimeZone($this->fix[1]));
|
||||
unset($this->fix);
|
||||
} elseif (isset($this->fix)) {
|
||||
$this->__construct($this->fix[0]);
|
||||
unset($this->fix);
|
||||
} else {
|
||||
parent::__wakeup();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
ibase_close($this->connection);
|
||||
@ibase_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
|
||||
public function escapeIdentifier($value)
|
||||
{
|
||||
return $value;
|
||||
return '"' . str_replace('"', '""', $value). '"';
|
||||
}
|
||||
|
||||
|
||||
@@ -333,9 +333,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function applyLimit(& $sql, $limit, $offset)
|
||||
{
|
||||
if ($limit >= 0 && $offset > 0) {
|
||||
// see http://scott.yang.id.au/2004/01/limit-in-select-statements-in-firebird/
|
||||
$sql = 'SELECT FIRST ' . (int) $limit . ($offset > 0 ? ' SKIP ' . (int) $offset : '') . ' * FROM (' . $sql . ')';
|
||||
if ($limit > 0 || $offset > 0) {
|
||||
// http://www.firebirdsql.org/refdocs/langrefupd20-select.html
|
||||
$sql = 'SELECT ' . ($limit > 0 ? 'FIRST ' . (int) $limit : '') . ($offset > 0 ? ' SKIP ' . (int) $offset : '') . ' * FROM (' . $sql . ')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function fetch($assoc)
|
||||
{
|
||||
$result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @
|
||||
$result = $assoc ? @ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : @ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @
|
||||
|
||||
if (ibase_errcode()) {
|
||||
if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
|
||||
|
@@ -78,7 +78,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
mssql_close($this->connection);
|
||||
@mssql_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -139,7 +139,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
mysql_close($this->connection);
|
||||
@mysql_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -138,7 +138,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
mysqli_close($this->connection);
|
||||
@mysqli_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -88,7 +88,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
odbc_close($this->connection);
|
||||
@odbc_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -44,6 +44,9 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
/** @var string Date and datetime format */
|
||||
private $fmtDate, $fmtDateTime;
|
||||
|
||||
/** @var int|FALSE Number of affected rows */
|
||||
private $affectedRows = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @throws Dibi\NotSupportedException
|
||||
@@ -92,7 +95,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
oci_close($this->connection);
|
||||
@oci_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +107,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
$res = oci_parse($this->connection, $sql);
|
||||
if ($res) {
|
||||
@oci_execute($res, $this->autocommit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT);
|
||||
@@ -112,6 +116,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
throw self::createException($err['message'], $err['code'], $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = oci_num_rows($res);
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
} else {
|
||||
@@ -147,7 +152,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function getAffectedRows()
|
||||
{
|
||||
throw new Dibi\NotImplementedException;
|
||||
return $this->affectedRows;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -111,7 +111,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
pg_close($this->connection);
|
||||
@pg_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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)) {
|
||||
@@ -94,7 +99,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
||||
*/
|
||||
public function disconnect()
|
||||
{
|
||||
sqlsrv_close($this->connection);
|
||||
@sqlsrv_close($this->connection); // @ - connection can be already disconnected
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
*/
|
||||
@@ -180,7 +181,7 @@ class Fluent implements IDataSource
|
||||
return $this;
|
||||
|
||||
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*\z#i', $arg)) { // identifier
|
||||
$args = ['%n', $arg];
|
||||
$args = [$clause === 'AS' ? '%N' : '%n', $arg];
|
||||
|
||||
} elseif (is_array($arg) || ($arg instanceof \Traversable && !$arg instanceof self)) { // any array
|
||||
if (isset(self::$modifiers[$clause])) {
|
||||
|
@@ -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,
|
||||
|
@@ -225,7 +225,7 @@ final class Translator
|
||||
case 'n': // key, key, ... identifier names
|
||||
foreach ($value as $k => $v) {
|
||||
if (is_string($k)) {
|
||||
$vx[] = $this->identifiers->$k . (empty($v) ? '' : ' AS ' . $this->identifiers->$v);
|
||||
$vx[] = $this->identifiers->$k . (empty($v) ? '' : ' AS ' . $this->driver->escapeIdentifier($v));
|
||||
} else {
|
||||
$pair = explode('%', $v, 2); // split into identifier & modifier
|
||||
$vx[] = $this->identifiers->{$pair[0]};
|
||||
@@ -380,9 +380,12 @@ final class Translator
|
||||
}
|
||||
|
||||
case 'by':
|
||||
case 'n': // identifier name
|
||||
case 'n': // composed identifier name
|
||||
return $this->identifiers->$value;
|
||||
|
||||
case 'N': // identifier name
|
||||
return $this->driver->escapeIdentifier($value);
|
||||
|
||||
case 'ex':
|
||||
case 'sql': // preserve as dibi-SQL (TODO: leave only %ex)
|
||||
$value = (string) $value;
|
||||
|
@@ -22,8 +22,8 @@ class dibi
|
||||
|
||||
/** version */
|
||||
const
|
||||
VERSION = '3.0.2',
|
||||
REVISION = 'released on 2016-01-29';
|
||||
VERSION = '3.0.6',
|
||||
REVISION = 'released on 2016-07-31';
|
||||
|
||||
/** 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.')
|
||||
{
|
||||
|
4
tests/.coveralls.yml
Normal file
4
tests/.coveralls.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
# for php-coveralls
|
||||
service_name: travis-ci
|
||||
coverage_clover: coverage.xml
|
||||
json_path: coverage.json
|
@@ -36,3 +36,15 @@ test(function () use ($config) { // query string
|
||||
Assert::same($config['driver'], $conn->getConfig('driver'));
|
||||
Assert::type('Dibi\Driver', $conn->getDriver());
|
||||
});
|
||||
|
||||
|
||||
test(function () use ($config) {
|
||||
$conn = new Connection($config);
|
||||
Assert::true($conn->isConnected());
|
||||
|
||||
$conn->disconnect();
|
||||
Assert::false($conn->isConnected());
|
||||
|
||||
$conn->disconnect();
|
||||
Assert::false($conn->isConnected());
|
||||
});
|
||||
|
@@ -26,19 +26,19 @@ Assert::same(
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->from('table')->as('tableAlias')
|
||||
$fluent->from('table')->as('table.Alias')
|
||||
->innerJoin('table1')->on('table.col = table1.col')
|
||||
->innerJoin('table2')->on('table.col = table2.col');
|
||||
|
||||
Assert::same(
|
||||
reformat('SELECT * , [a] , [b] AS [bAlias] , [c], [d], [e] , [d] FROM [table] AS [tableAlias] INNER JOIN [table1] ON table.col = table1.col INNER JOIN [table2] ON table.col = table2.col'),
|
||||
reformat('SELECT * , [a] , [b] AS [bAlias] , [c], [d], [e] , [d] FROM [table] AS [table.Alias] INNER JOIN [table1] ON table.col = table1.col INNER JOIN [table2] ON table.col = table2.col'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
$fluent->from('anotherTable');
|
||||
|
||||
Assert::same(
|
||||
reformat('SELECT * , [a] , [b] AS [bAlias] , [c], [d], [e] , [d] FROM [table] AS [tableAlias] INNER JOIN [table1] ON table.col = table1.col INNER JOIN [table2] ON table.col = table2.col , [anotherTable]'),
|
||||
reformat('SELECT * , [a] , [b] AS [bAlias] , [c], [d], [e] , [d] FROM [table] AS [table.Alias] INNER JOIN [table1] ON table.col = table1.col INNER JOIN [table2] ON table.col = table2.col , [anotherTable]'),
|
||||
(string) $fluent
|
||||
);
|
||||
|
||||
|
@@ -139,7 +139,7 @@ test(function () {
|
||||
Assert::same(['col' => 1], $result->test(['col' => TRUE]));
|
||||
Assert::same(['col' => 0], $result->test(['col' => FALSE]));
|
||||
|
||||
Assert::same(['col' => 0], $result->test(['col' => '']));
|
||||
Assert::same(['col' => 0], @$result->test(['col' => ''])); // triggers warning in PHP 7.1
|
||||
Assert::same(['col' => 0], $result->test(['col' => '0']));
|
||||
Assert::same(['col' => 1], $result->test(['col' => '1']));
|
||||
Assert::same(['col' => 10], $result->test(['col' => '10']));
|
||||
|
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());
|
@@ -280,7 +280,7 @@ $array2 = ['one', 'two', 'three'];
|
||||
$array3 = [
|
||||
'col1' => 'one',
|
||||
'col2' => 'two',
|
||||
'col3' => 'three',
|
||||
'col3' => 'thr.ee',
|
||||
];
|
||||
$array4 = [
|
||||
'a' => 12,
|
||||
@@ -301,8 +301,8 @@ WHERE (`test`.`a` LIKE '1995-03-01'
|
||||
OR `b2` IN ('1', '2', '3' )
|
||||
OR `b3` IN ( )
|
||||
OR `b4` IN ( 'one', 'two', 'three' )
|
||||
OR `b5` IN (`col1` AS `one`, `col2` AS `two`, `col3` AS `three` )
|
||||
OR `b6` IN ('one', 'two', 'three')
|
||||
OR `b5` IN (`col1` AS `one`, `col2` AS `two`, `col3` AS `thr.ee` )
|
||||
OR `b6` IN ('one', 'two', 'thr.ee')
|
||||
OR `b7` IN (NULL)
|
||||
OR `b8` IN (RAND() `col1` > `col2` )
|
||||
OR `b9` IN (RAND(), [col1] > [col2] )
|
||||
@@ -322,8 +322,8 @@ WHERE ("test"."a" LIKE \'1995-03-01\'
|
||||
OR "b2" IN (\'1\', \'2\', \'3\' )
|
||||
OR "b3" IN ( )
|
||||
OR "b4" IN ( \'one\', \'two\', \'three\' )
|
||||
OR "b5" IN ("col1" AS "one", "col2" AS "two", "col3" AS "three" )
|
||||
OR "b6" IN (\'one\', \'two\', \'three\')
|
||||
OR "b5" IN ("col1" AS "one", "col2" AS "two", "col3" AS "thr.ee" )
|
||||
OR "b6" IN (\'one\', \'two\', \'thr.ee\')
|
||||
OR "b7" IN (NULL)
|
||||
OR "b8" IN (RAND() "col1" > "col2" )
|
||||
OR "b9" IN (RAND(), [col1] > [col2] )
|
||||
@@ -343,8 +343,8 @@ WHERE ([test].[a] LIKE #03/01/1995#
|
||||
OR [b2] IN ('1', '2', '3' )
|
||||
OR [b3] IN ( )
|
||||
OR [b4] IN ( 'one', 'two', 'three' )
|
||||
OR [b5] IN ([col1] AS [one], [col2] AS [two], [col3] AS [three] )
|
||||
OR [b6] IN ('one', 'two', 'three')
|
||||
OR [b5] IN ([col1] AS [one], [col2] AS [two], [col3] AS [thr.ee] )
|
||||
OR [b6] IN ('one', 'two', 'thr.ee')
|
||||
OR [b7] IN (NULL)
|
||||
OR [b8] IN (RAND() [col1] > [col2] )
|
||||
OR [b9] IN (RAND(), [col1] > [col2] )
|
||||
@@ -364,8 +364,8 @@ WHERE ([test].[a] LIKE '1995-03-01'
|
||||
OR [b2] IN ('1', '2', '3' )
|
||||
OR [b3] IN ( )
|
||||
OR [b4] IN ( 'one', 'two', 'three' )
|
||||
OR [b5] IN ([col1] AS [one], [col2] AS [two], [col3] AS [three] )
|
||||
OR [b6] IN ('one', 'two', 'three')
|
||||
OR [b5] IN ([col1] AS [one], [col2] AS [two], [col3] AS [thr.ee] )
|
||||
OR [b6] IN ('one', 'two', 'thr.ee')
|
||||
OR [b7] IN (NULL)
|
||||
OR [b8] IN (RAND() [col1] > [col2] )
|
||||
OR [b9] IN (RAND(), [col1] > [col2] )
|
||||
@@ -522,7 +522,7 @@ Assert::same(
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT INTO 0'),
|
||||
$conn->translate('INSERT INTO %f', 'ahoj')
|
||||
@$conn->translate('INSERT INTO %f', 'ahoj') // triggers warning in PHP 7.1
|
||||
);
|
||||
|
||||
|
||||
@@ -542,6 +542,12 @@ Assert::same(
|
||||
);
|
||||
|
||||
|
||||
Assert::same(
|
||||
reformat('SELECT [a].[b] AS [c.d]'),
|
||||
$conn->translate('SELECT %n AS %N', 'a.b', 'c.d')
|
||||
);
|
||||
|
||||
|
||||
setLocale(LC_ALL, 'czech');
|
||||
|
||||
Assert::same(
|
||||
|
@@ -1,5 +1,3 @@
|
||||
/*!40102 SET storage_engine = InnoDB */;
|
||||
|
||||
DROP DATABASE IF EXISTS dibi_test;
|
||||
CREATE DATABASE dibi_test;
|
||||
USE dibi_test;
|
||||
|
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