mirror of
https://github.com/dg/dibi.git
synced 2025-09-04 19:55:26 +02:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e8559898f1 | ||
|
ece85e8b48 | ||
|
acd5ac8616 | ||
|
44876973f5 | ||
|
0e5d951dfb | ||
|
126422ad7e | ||
|
277f52c928 | ||
|
80ac569621 | ||
|
d9628f933d | ||
|
f7009f3e0c | ||
|
36d30c1fcf | ||
|
ae6c8756b6 | ||
|
6b2c996b16 | ||
|
718c617764 | ||
|
6194152e67 | ||
|
d39603e23d |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -2,4 +2,5 @@
|
|||||||
.gitignore export-ignore
|
.gitignore export-ignore
|
||||||
.github export-ignore
|
.github export-ignore
|
||||||
.travis.yml export-ignore
|
.travis.yml export-ignore
|
||||||
|
appveyor.yml export-ignore
|
||||||
tests/ export-ignore
|
tests/ export-ignore
|
||||||
|
@@ -5,11 +5,6 @@ php:
|
|||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
- hhvm
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- php: hhvm
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/tester tests -s -p php -c tests/php-unix.ini $COVERAGE
|
- vendor/bin/tester tests -s -p php -c tests/php-unix.ini $COVERAGE
|
||||||
|
10
appveyor.yml
10
appveyor.yml
@@ -8,7 +8,7 @@ clone_folder: c:\projects\dibi
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
- mssql2012sp1
|
- mssql2012sp1
|
||||||
- mssql2014
|
# - mssql2014
|
||||||
- mysql
|
- mysql
|
||||||
|
|
||||||
init:
|
init:
|
||||||
@@ -20,8 +20,8 @@ install:
|
|||||||
- IF EXIST c:\php5 (SET PHP=0) ELSE (SET PHP=1)
|
- IF EXIST c:\php5 (SET PHP=0) ELSE (SET PHP=1)
|
||||||
- IF %PHP%==1 mkdir c:\php5
|
- IF %PHP%==1 mkdir c:\php5
|
||||||
- IF %PHP%==1 cd 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 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-5.6.14-Win32-VC11-x86.zip >nul
|
- IF %PHP%==1 7z x php.zip >nul
|
||||||
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
||||||
- IF %PHP%==1 echo extension=php_openssl.dll >> 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
|
- 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 EXIST c:\php7 (SET PHP=0) ELSE (SET PHP=1)
|
||||||
- IF %PHP%==1 mkdir c:\php7
|
- IF %PHP%==1 mkdir c:\php7
|
||||||
- IF %PHP%==1 cd 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 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-7.0.3-Win32-VC14-x86.zip >nul
|
- IF %PHP%==1 7z x php.zip >nul
|
||||||
- IF %PHP%==1 echo extension_dir=ext >> php.ini
|
- 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 appveyor DownloadFile https://files.nette.org/misc/php-sqlsrv.zip
|
||||||
- IF %PHP%==1 7z x php-sqlsrv.zip >nul
|
- IF %PHP%==1 7z x php-sqlsrv.zip >nul
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
||||||
|
|
||||||
<h1>Fetching Examples | dibi</h1>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
||||||
@@ -10,6 +6,12 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
|
|||||||
|
|
||||||
Tracy\Debugger::enable();
|
Tracy\Debugger::enable();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
<h1>Fetching Examples | dibi</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
dibi::connect([
|
dibi::connect([
|
||||||
'driver' => 'sqlite3',
|
'driver' => 'sqlite3',
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
||||||
|
|
||||||
<h1>Result Set Data Types | dibi</h1>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Dibi\Type;
|
use Dibi\Type;
|
||||||
@@ -14,6 +10,12 @@ Tracy\Debugger::enable();
|
|||||||
|
|
||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
<h1>Result Set Data Types | dibi</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
dibi::connect([
|
dibi::connect([
|
||||||
'driver' => 'sqlite3',
|
'driver' => 'sqlite3',
|
||||||
|
@@ -1,9 +1,3 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
||||||
|
|
||||||
<h1>Tracy & SQL Exceptions | dibi</h1>
|
|
||||||
|
|
||||||
<p>Dibi can display and log exceptions via <a href="https://tracy.nette.org">Tracy</a>.</p>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
||||||
@@ -31,3 +25,9 @@ $panel->register($connection);
|
|||||||
|
|
||||||
// throws error because SQL is bad
|
// throws error because SQL is bad
|
||||||
dibi::query('SELECT FROM customers WHERE customer_id < ?', 38);
|
dibi::query('SELECT FROM customers WHERE customer_id < ?', 38);
|
||||||
|
|
||||||
|
?><!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
<h1>Tracy & SQL Exceptions | dibi</h1>
|
||||||
|
|
||||||
|
<p>Dibi can display and log exceptions via <a href="https://tracy.nette.org">Tracy</a>.</p>
|
||||||
|
@@ -1,11 +1,3 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
||||||
|
|
||||||
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
|
|
||||||
|
|
||||||
<h1>Tracy | dibi</h1>
|
|
||||||
|
|
||||||
<p>Dibi can log queries and dump variables to the <a href="https://tracy.nette.org">Tracy</a>.</p>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
||||||
@@ -36,3 +28,13 @@ dibi::query('SELECT 123');
|
|||||||
|
|
||||||
// result set will be dumped
|
// result set will be dumped
|
||||||
Tracy\Debugger::barDump(dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]');
|
Tracy\Debugger::barDump(dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]');
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
|
||||||
|
|
||||||
|
<h1>Tracy | dibi</h1>
|
||||||
|
|
||||||
|
<p>Dibi can log queries and dump variables to the <a href="https://tracy.nette.org">Tracy</a>.</p>
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
||||||
|
|
||||||
<h1>Using Extension Methods | dibi</h1>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
if (@!include __DIR__ . '/../vendor/autoload.php') {
|
||||||
@@ -10,6 +6,12 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
|
|||||||
|
|
||||||
Tracy\Debugger::enable();
|
Tracy\Debugger::enable();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
<h1>Using Extension Methods | dibi</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
dibi::connect([
|
dibi::connect([
|
||||||
'driver' => 'sqlite3',
|
'driver' => 'sqlite3',
|
||||||
|
@@ -63,7 +63,7 @@ class Panel implements Tracy\IBarPanel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns blue-screen custom tab.
|
* Returns blue-screen custom tab.
|
||||||
* @return mixed
|
* @return array|NULL
|
||||||
*/
|
*/
|
||||||
public static function renderException($e)
|
public static function renderException($e)
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ class Panel implements Tracy\IBarPanel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML code for custom tab. (Tracy\IBarPanel)
|
* Returns HTML code for custom tab. (Tracy\IBarPanel)
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTab()
|
public function getTab()
|
||||||
{
|
{
|
||||||
@@ -88,35 +88,39 @@ class Panel implements Tracy\IBarPanel
|
|||||||
$totalTime += $event->time;
|
$totalTime += $event->time;
|
||||||
}
|
}
|
||||||
return '<span title="dibi"><svg viewBox="0 0 2048 2048" style="vertical-align: bottom; width:1.23em; height:1.55em"><path fill="' . ($count ? '#b079d6' : '#aaa') . '" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103-128t280-93.5 385-34.5z"/></svg><span class="tracy-label">'
|
return '<span title="dibi"><svg viewBox="0 0 2048 2048" style="vertical-align: bottom; width:1.23em; height:1.55em"><path fill="' . ($count ? '#b079d6' : '#aaa') . '" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103-128t280-93.5 385-34.5z"/></svg><span class="tracy-label">'
|
||||||
. $count . ' queries'
|
. $count . ' queries'
|
||||||
. ($totalTime ? sprintf(' / %0.1f ms', $totalTime * 1000) : '')
|
. ($totalTime ? ' / ' . number_format($totalTime * 1000, 1, '.', ' ') . ' ms' : '')
|
||||||
. '</span></span>';
|
. '</span></span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML code for custom panel. (Tracy\IBarPanel)
|
* Returns HTML code for custom panel. (Tracy\IBarPanel)
|
||||||
* @return mixed
|
* @return string|NULL
|
||||||
*/
|
*/
|
||||||
public function getPanel()
|
public function getPanel()
|
||||||
{
|
{
|
||||||
|
if (!$this->events) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
$totalTime = $s = NULL;
|
$totalTime = $s = NULL;
|
||||||
$h = 'htmlSpecialChars';
|
|
||||||
foreach ($this->events as $event) {
|
foreach ($this->events as $event) {
|
||||||
$totalTime += $event->time;
|
$totalTime += $event->time;
|
||||||
|
$connection = $event->connection;
|
||||||
$explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
|
$explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
|
||||||
if ($this->explain && $event->type === Event::SELECT) {
|
if ($this->explain && $event->type === Event::SELECT) {
|
||||||
try {
|
try {
|
||||||
$backup = [$event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
|
$backup = [$connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
|
||||||
$event->connection->onEvent = NULL;
|
$connection->onEvent = NULL;
|
||||||
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
|
$cmd = is_string($this->explain) ? $this->explain : ($connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
|
||||||
$explain = Helpers::dump(@$event->connection->nativeQuery("$cmd $event->sql"), TRUE);
|
$explain = @Helpers::dump($connection->nativeQuery("$cmd $event->sql"), TRUE);
|
||||||
} catch (Dibi\Exception $e) {
|
} catch (Dibi\Exception $e) {
|
||||||
}
|
}
|
||||||
list($event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
|
list($connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= '<tr><td>' . sprintf('%0.3f', $event->time * 1000);
|
$s .= '<tr><td>' . number_format($event->time * 1000, 3, '.', ' ');
|
||||||
if ($explain) {
|
if ($explain) {
|
||||||
static $counter;
|
static $counter;
|
||||||
$counter++;
|
$counter++;
|
||||||
@@ -131,17 +135,19 @@ class Panel implements Tracy\IBarPanel
|
|||||||
$s .= Tracy\Helpers::editorLink($event->source[0], $event->source[1]);//->class('tracy-DibiProfiler-source');
|
$s .= Tracy\Helpers::editorLink($event->source[0], $event->source[1]);//->class('tracy-DibiProfiler-source');
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= "</td><td>{$event->count}</td><td>{$h($event->connection->getConfig('driver') . '/' . $event->connection->getConfig('name'))}</td></tr>";
|
$s .= "</td><td>{$event->count}</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty($this->events) ? '' :
|
return '<style> #tracy-debug td.tracy-DibiProfiler-sql { background: white !important }
|
||||||
'<style> #tracy-debug td.tracy-DibiProfiler-sql { background: white !important }
|
|
||||||
#tracy-debug .tracy-DibiProfiler-source { color: #999 !important }
|
#tracy-debug .tracy-DibiProfiler-source { color: #999 !important }
|
||||||
#tracy-debug tracy-DibiProfiler tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>
|
#tracy-debug tracy-DibiProfiler tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>
|
||||||
<h1>Queries: ' . count($this->events) . ($totalTime === NULL ? '' : sprintf(', time: %0.3f ms', $totalTime * 1000)) . '</h1>
|
<h1>Queries: ' . count($this->events)
|
||||||
|
. ($totalTime === NULL ? '' : ', time: ' . number_format($totalTime * 1000, 1, '.', ' ') . ' ms') . ', '
|
||||||
|
. htmlSpecialChars($connection->getConfig('driver') . ($connection->getConfig('name') ? '/' . $connection->getConfig('name') : '')
|
||||||
|
. ($connection->getConfig('host') ? ' @ ' . $connection->getConfig('host') : '')) . '</h1>
|
||||||
<div class="tracy-inner tracy-DibiProfiler">
|
<div class="tracy-inner tracy-DibiProfiler">
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Time ms</th><th>SQL Statement</th><th>Rows</th><th>Connection</th></tr>' . $s . '
|
<tr><th>Time ms</th><th>SQL Statement</th><th>Rows</th></tr>' . $s . '
|
||||||
</table>
|
</table>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
@@ -97,7 +97,7 @@ class Connection
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
||||||
// profiler
|
// profiler
|
||||||
$profilerCfg = & $config['profiler'];
|
$profilerCfg = &$config['profiler'];
|
||||||
if (is_scalar($profilerCfg)) {
|
if (is_scalar($profilerCfg)) {
|
||||||
$profilerCfg = ['run' => (bool) $profilerCfg];
|
$profilerCfg = ['run' => (bool) $profilerCfg];
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ class Connection
|
|||||||
|
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public static function alias(& $config, $key, $alias)
|
public static function alias(&$config, $key, $alias)
|
||||||
{
|
{
|
||||||
trigger_error(__METHOD__ . '() is deprecated, use Helpers::alias().', E_USER_DEPRECATED);
|
trigger_error(__METHOD__ . '() is deprecated, use Helpers::alias().', E_USER_DEPRECATED);
|
||||||
Helpers::alias($config, $key, $alias);
|
Helpers::alias($config, $key, $alias);
|
||||||
@@ -225,7 +225,7 @@ class Connection
|
|||||||
/**
|
/**
|
||||||
* Generates (translates) and executes SQL query.
|
* Generates (translates) and executes SQL query.
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
* @return Result|int result set object (if any)
|
* @return Result|int result set or number of affected rows
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
final public function query($args)
|
final public function query($args)
|
||||||
@@ -303,7 +303,7 @@ class Connection
|
|||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
* @return Result|int result set object (if any)
|
* @return Result|int result set or number of affected rows
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
final public function nativeQuery($sql)
|
final public function nativeQuery($sql)
|
||||||
@@ -473,7 +473,7 @@ class Connection
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string column name
|
* @param mixed column name
|
||||||
* @return Fluent
|
* @return Fluent
|
||||||
*/
|
*/
|
||||||
public function select($args)
|
public function select($args)
|
||||||
@@ -555,7 +555,7 @@ class Connection
|
|||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
* @return Row|bool
|
* @return Row|FALSE
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function fetch($args)
|
public function fetch($args)
|
||||||
@@ -581,7 +581,7 @@ class Connection
|
|||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
|
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
* @return string|bool
|
* @return mixed
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function fetchSingle($args)
|
public function fetchSingle($args)
|
||||||
|
@@ -40,10 +40,10 @@ class DataSource implements IDataSource
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
private $conds = [];
|
private $conds = [];
|
||||||
|
|
||||||
/** @var int */
|
/** @var int|NULL */
|
||||||
private $offset;
|
private $offset;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int|NULL */
|
||||||
private $limit;
|
private $limit;
|
||||||
|
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ class DataSource implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Limits number of rows.
|
* Limits number of rows.
|
||||||
* @param int limit
|
* @param int|NULL limit
|
||||||
* @param int offset
|
* @param int offset
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
@@ -168,7 +168,7 @@ class DataSource implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates, executes SQL query and fetches the single row.
|
* Generates, executes SQL query and fetches the single row.
|
||||||
* @return Row|FALSE array on success, FALSE if no next record
|
* @return Row|FALSE
|
||||||
*/
|
*/
|
||||||
public function fetch()
|
public function fetch()
|
||||||
{
|
{
|
||||||
|
@@ -15,6 +15,9 @@ class DateTime extends \DateTime
|
|||||||
{
|
{
|
||||||
use Strict;
|
use Strict;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|int
|
||||||
|
*/
|
||||||
public function __construct($time = 'now', \DateTimeZone $timezone = NULL)
|
public function __construct($time = 'now', \DateTimeZone $timezone = NULL)
|
||||||
{
|
{
|
||||||
if (is_numeric($time)) {
|
if (is_numeric($time)) {
|
||||||
|
@@ -28,16 +28,16 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
const ERROR_EXCEPTION_THROWN = -836;
|
const ERROR_EXCEPTION_THROWN = -836;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $autoFree = TRUE;
|
private $autoFree = TRUE;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $transaction;
|
private $transaction;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -60,7 +60,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
Dibi\Helpers::alias($config, 'database', 'db');
|
Dibi\Helpers::alias($config, 'database', 'db');
|
||||||
|
|
||||||
@@ -123,6 +123,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
} elseif (is_resource($res)) {
|
} elseif (is_resource($res)) {
|
||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -215,7 +216,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return resource
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -260,24 +261,40 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
return '"' . str_replace('"', '""', $value). '"';
|
return '"' . str_replace('"', '""', $value). '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -287,6 +304,10 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -329,9 +350,12 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit > 0 || $offset > 0) {
|
if ($limit > 0 || $offset > 0) {
|
||||||
// http://www.firebirdsql.org/refdocs/langrefupd20-select.html
|
// http://www.firebirdsql.org/refdocs/langrefupd20-select.html
|
||||||
@@ -411,7 +435,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return resource
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -26,10 +26,10 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
{
|
{
|
||||||
use Dibi\Strict;
|
use Dibi\Strict;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -52,7 +52,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
@@ -98,6 +98,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
} elseif (is_resource($res)) {
|
} elseif (is_resource($res)) {
|
||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +165,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -200,7 +201,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -209,12 +210,20 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
|
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
|
||||||
@@ -222,12 +231,20 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -237,6 +254,10 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -280,9 +301,12 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($offset) {
|
if ($offset) {
|
||||||
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
||||||
@@ -375,7 +399,7 @@ class MsSqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -36,10 +36,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
const ERROR_DUPLICATE_ENTRY = 1062;
|
const ERROR_DUPLICATE_ENTRY = 1062;
|
||||||
const ERROR_DATA_TRUNCATED = 1265;
|
const ERROR_DATA_TRUNCATED = 1265;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -65,7 +65,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
@@ -243,7 +243,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -279,7 +279,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -291,6 +291,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
@@ -300,6 +304,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
// @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
|
// @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
|
||||||
@@ -307,12 +315,20 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -322,6 +338,10 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -365,9 +385,12 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
@@ -469,7 +492,7 @@ class MySqlDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -37,10 +37,10 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
const ERROR_DUPLICATE_ENTRY = 1062;
|
const ERROR_DUPLICATE_ENTRY = 1062;
|
||||||
const ERROR_DATA_TRUNCATED = 1265;
|
const ERROR_DATA_TRUNCATED = 1265;
|
||||||
|
|
||||||
/** @var mysqli Connection resource */
|
/** @var \mysqli|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var mysqli_result Resultset resource */
|
/** @var \mysqli_result|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -66,7 +66,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
mysqli_report(MYSQLI_REPORT_OFF);
|
mysqli_report(MYSQLI_REPORT_OFF);
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
@@ -93,8 +93,8 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$foo = & $config['flags'];
|
$foo = &$config['flags'];
|
||||||
$foo = & $config['database'];
|
$foo = &$config['database'];
|
||||||
|
|
||||||
$this->connection = mysqli_init();
|
$this->connection = mysqli_init();
|
||||||
if (isset($config['options'])) {
|
if (isset($config['options'])) {
|
||||||
@@ -158,6 +158,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
} elseif (is_object($res)) {
|
} elseif (is_object($res)) {
|
||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,7 +259,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mysqli
|
* @return \mysqli
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -278,7 +279,6 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param mysqli_result
|
|
||||||
* @return Dibi\ResultDriver
|
* @return Dibi\ResultDriver
|
||||||
*/
|
*/
|
||||||
public function createResultDriver(\mysqli_result $resource)
|
public function createResultDriver(\mysqli_result $resource)
|
||||||
@@ -294,7 +294,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -303,24 +303,40 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
return '`' . str_replace('`', '``', $value) . '`';
|
return '`' . str_replace('`', '``', $value) . '`';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -330,6 +346,10 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -373,9 +393,12 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
@@ -488,7 +511,7 @@ class MySqliDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mysqli_result
|
* @return \mysqli_result|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -25,10 +25,10 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
{
|
{
|
||||||
use Dibi\Strict;
|
use Dibi\Strict;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -57,7 +57,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
@@ -110,6 +110,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
$this->affectedRows = odbc_num_rows($res);
|
$this->affectedRows = odbc_num_rows($res);
|
||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -225,7 +226,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -234,24 +235,40 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
return '[' . str_replace(['[', ']'], ['[[', ']]'], $value) . ']';
|
return '[' . str_replace(['[', ']'], ['[[', ']]'], $value) . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -261,6 +278,10 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -304,9 +325,12 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($offset) {
|
if ($offset) {
|
||||||
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
||||||
@@ -413,7 +437,7 @@ class OdbcDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -29,10 +29,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
{
|
{
|
||||||
use Dibi\Strict;
|
use Dibi\Strict;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -64,9 +64,9 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
$foo = & $config['charset'];
|
$foo = &$config['charset'];
|
||||||
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
||||||
$this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
|
$this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
|
||||||
|
|
||||||
@@ -123,6 +123,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
$err = oci_error($this->connection);
|
$err = oci_error($this->connection);
|
||||||
throw new Dibi\DriverException($err['message'], $err['code'], $sql);
|
throw new Dibi\DriverException($err['message'], $err['code'], $sql);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -212,7 +213,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -248,7 +249,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -257,12 +258,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested
|
return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
// @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
|
// @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
|
||||||
@@ -270,12 +279,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -285,6 +302,10 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -329,9 +350,12 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
@@ -427,7 +451,7 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -30,7 +30,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
/** @var PDO Connection resource */
|
/** @var PDO Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var \PDOStatement Resultset resource */
|
/** @var \PDOStatement|NULL Resultset resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var int|FALSE Affected rows */
|
/** @var int|FALSE Affected rows */
|
||||||
@@ -40,7 +40,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
private $driverName;
|
private $driverName;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $serverVersion;
|
private $serverVersion = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,10 +59,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
$foo = & $config['dsn'];
|
$foo = &$config['dsn'];
|
||||||
$foo = & $config['options'];
|
$foo = &$config['options'];
|
||||||
Dibi\Helpers::alias($config, 'resource', 'pdo');
|
Dibi\Helpers::alias($config, 'resource', 'pdo');
|
||||||
|
|
||||||
if ($config['resource'] instanceof PDO) {
|
if ($config['resource'] instanceof PDO) {
|
||||||
@@ -112,7 +112,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
if (isset($list[$cmd])) {
|
if (isset($list[$cmd])) {
|
||||||
$this->affectedRows = $this->connection->exec($sql);
|
$this->affectedRows = $this->connection->exec($sql);
|
||||||
if ($this->affectedRows !== FALSE) {
|
if ($this->affectedRows !== FALSE) {
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$res = $this->connection->query($sql);
|
$res = $this->connection->query($sql);
|
||||||
@@ -254,7 +254,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -267,6 +267,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
if ($this->driverName === 'odbc') {
|
if ($this->driverName === 'odbc') {
|
||||||
@@ -277,6 +281,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
switch ($this->driverName) {
|
switch ($this->driverName) {
|
||||||
@@ -304,16 +312,24 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
if ($this->driverName === 'pgsql') {
|
if ($this->driverName === 'pgsql') {
|
||||||
return $value ? 'TRUE' : 'FALSE';
|
return $value ? 'TRUE' : 'FALSE';
|
||||||
} else {
|
} else {
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -323,6 +339,10 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -394,9 +414,12 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
@@ -548,7 +571,7 @@ class PdoDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return \PDOStatement
|
* @return \PDOStatement|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -26,10 +26,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
{
|
{
|
||||||
use Dibi\Strict;
|
use Dibi\Strict;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -55,7 +55,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
$error = NULL;
|
$error = NULL;
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
@@ -78,7 +78,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_error_handler(function($severity, $message) use (& $error) {
|
set_error_handler(function($severity, $message) use (&$error) {
|
||||||
$error = $message;
|
$error = $message;
|
||||||
});
|
});
|
||||||
if (empty($config['persistent'])) {
|
if (empty($config['persistent'])) {
|
||||||
@@ -145,6 +145,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -256,7 +257,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -292,7 +293,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -304,6 +305,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
@@ -313,6 +318,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
|
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
|
||||||
@@ -320,12 +329,20 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 'TRUE' : 'FALSE';
|
return $value ? 'TRUE' : 'FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -335,6 +352,10 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -380,9 +401,12 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
@@ -475,7 +499,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -27,10 +27,10 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
{
|
{
|
||||||
use Dibi\Strict;
|
use Dibi\Strict;
|
||||||
|
|
||||||
/** @var SQLite3 Connection resource */
|
/** @var SQLite3|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var \SQLite3Result Resultset resource */
|
/** @var \SQLite3Result|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -59,7 +59,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
Dibi\Helpers::alias($config, 'database', 'file');
|
Dibi\Helpers::alias($config, 'database', 'file');
|
||||||
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
||||||
@@ -118,6 +118,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
} elseif ($res instanceof \SQLite3Result) {
|
} elseif ($res instanceof \SQLite3Result) {
|
||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return SQLite3
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -245,7 +246,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -254,24 +255,40 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "X'" . bin2hex((string) $value) . "'";
|
return "X'" . bin2hex((string) $value) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
return '[' . strtr($value, '[]', ' ') . ']';
|
return '[' . strtr($value, '[]', ' ') . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -281,6 +298,10 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -324,9 +345,12 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
@@ -431,7 +455,7 @@ class Sqlite3Driver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return \SQLite3Result|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -29,10 +29,10 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
{
|
{
|
||||||
use Dibi\Strict;
|
use Dibi\Strict;
|
||||||
|
|
||||||
/** @var resource Connection resource */
|
/** @var resource|NULL */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/** @var resource Resultset resource */
|
/** @var resource|NULL */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@@ -42,7 +42,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
private $affectedRows = FALSE;
|
private $affectedRows = FALSE;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $version;
|
private $version = '';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +61,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public function connect(array & $config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
Helpers::alias($config, 'options|UID', 'username');
|
Helpers::alias($config, 'options|UID', 'username');
|
||||||
Helpers::alias($config, 'options|PWD', 'password');
|
Helpers::alias($config, 'options|PWD', 'password');
|
||||||
@@ -122,6 +122,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
$this->affectedRows = sqlsrv_rows_affected($res);
|
$this->affectedRows = sqlsrv_rows_affected($res);
|
||||||
return $this->createResultDriver($res);
|
return $this->createResultDriver($res);
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,7 +189,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource()
|
||||||
{
|
{
|
||||||
@@ -224,7 +225,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
public function escapeText($value)
|
public function escapeText($value)
|
||||||
@@ -233,12 +234,20 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBinary($value)
|
public function escapeBinary($value)
|
||||||
{
|
{
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeIdentifier($value)
|
public function escapeIdentifier($value)
|
||||||
{
|
{
|
||||||
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
|
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
|
||||||
@@ -246,12 +255,20 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeBool($value)
|
public function escapeBool($value)
|
||||||
{
|
{
|
||||||
return $value ? 1 : 0;
|
return $value ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDate($value)
|
public function escapeDate($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -261,6 +278,10 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function escapeDateTime($value)
|
public function escapeDateTime($value)
|
||||||
{
|
{
|
||||||
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
if (!$value instanceof \DateTime && !$value instanceof \DateTimeInterface) {
|
||||||
@@ -304,14 +325,17 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(& $sql, $limit, $offset)
|
public function applyLimit(&$sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 || $offset < 0) {
|
if ($limit < 0 || $offset < 0) {
|
||||||
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
throw new Dibi\NotSupportedException('Negative offset or limit.');
|
||||||
|
|
||||||
} elseif (version_compare($this->version, 11, '<')) { // 11 == SQL Server 2012
|
} elseif (version_compare($this->version, '11', '<')) { // 11 == SQL Server 2012
|
||||||
if ($offset) {
|
if ($offset) {
|
||||||
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
throw new Dibi\NotSupportedException('Offset is not supported by this database.');
|
||||||
|
|
||||||
@@ -405,7 +429,7 @@ class SqlsrvDriver implements Dibi\Driver, Dibi\ResultDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return resource|NULL
|
||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
|
@@ -130,19 +130,19 @@ class Fluent implements IDataSource
|
|||||||
if (isset(self::$masks[$clause])) {
|
if (isset(self::$masks[$clause])) {
|
||||||
$this->clauses = array_fill_keys(self::$masks[$clause], NULL);
|
$this->clauses = array_fill_keys(self::$masks[$clause], NULL);
|
||||||
}
|
}
|
||||||
$this->cursor = & $this->clauses[$clause];
|
$this->cursor = &$this->clauses[$clause];
|
||||||
$this->cursor = [];
|
$this->cursor = [];
|
||||||
$this->command = $clause;
|
$this->command = $clause;
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto-switch to a clause
|
// auto-switch to a clause
|
||||||
if (isset(self::$clauseSwitches[$clause])) {
|
if (isset(self::$clauseSwitches[$clause])) {
|
||||||
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
|
$this->cursor = &$this->clauses[self::$clauseSwitches[$clause]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists($clause, $this->clauses)) {
|
if (array_key_exists($clause, $this->clauses)) {
|
||||||
// append to clause
|
// append to clause
|
||||||
$this->cursor = & $this->clauses[$clause];
|
$this->cursor = &$this->clauses[$clause];
|
||||||
|
|
||||||
// TODO: really delete?
|
// TODO: really delete?
|
||||||
if ($args === [self::REMOVE]) {
|
if ($args === [self::REMOVE]) {
|
||||||
@@ -211,7 +211,7 @@ class Fluent implements IDataSource
|
|||||||
*/
|
*/
|
||||||
public function clause($clause)
|
public function clause($clause)
|
||||||
{
|
{
|
||||||
$this->cursor = & $this->clauses[self::$normalizer->$clause];
|
$this->cursor = &$this->clauses[self::$normalizer->$clause];
|
||||||
if ($this->cursor === NULL) {
|
if ($this->cursor === NULL) {
|
||||||
$this->cursor = [];
|
$this->cursor = [];
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ class Fluent implements IDataSource
|
|||||||
/**
|
/**
|
||||||
* Generates and executes SQL query.
|
* Generates and executes SQL query.
|
||||||
* @param mixed what to return?
|
* @param mixed what to return?
|
||||||
* @return Result|int result set object (if any)
|
* @return Result|int result set or number of affected rows
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute($return = NULL)
|
public function execute($return = NULL)
|
||||||
@@ -319,7 +319,7 @@ class Fluent implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates, executes SQL query and fetches the single row.
|
* Generates, executes SQL query and fetches the single row.
|
||||||
* @return Row|FALSE array on success, FALSE if no next record
|
* @return Row|FALSE
|
||||||
*/
|
*/
|
||||||
public function fetch()
|
public function fetch()
|
||||||
{
|
{
|
||||||
@@ -512,10 +512,10 @@ class Fluent implements IDataSource
|
|||||||
{
|
{
|
||||||
// remove references
|
// remove references
|
||||||
foreach ($this->clauses as $clause => $val) {
|
foreach ($this->clauses as $clause => $val) {
|
||||||
$this->clauses[$clause] = & $val;
|
$this->clauses[$clause] = &$val;
|
||||||
unset($val);
|
unset($val);
|
||||||
}
|
}
|
||||||
$this->cursor = & $foo;
|
$this->cursor = &$foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -50,14 +50,14 @@ class Helpers
|
|||||||
if ($i === 0) {
|
if ($i === 0) {
|
||||||
echo "\n<table class=\"dump\">\n<thead>\n\t<tr>\n\t\t<th>#row</th>\n";
|
echo "\n<table class=\"dump\">\n<thead>\n\t<tr>\n\t\t<th>#row</th>\n";
|
||||||
foreach ($row as $col => $foo) {
|
foreach ($row as $col => $foo) {
|
||||||
echo "\t\t<th>" . htmlSpecialChars($col) . "</th>\n";
|
echo "\t\t<th>" . htmlSpecialChars((string) $col) . "</th>\n";
|
||||||
}
|
}
|
||||||
echo "\t</tr>\n</thead>\n<tbody>\n";
|
echo "\t</tr>\n</thead>\n<tbody>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "\t<tr>\n\t\t<th>", $i, "</th>\n";
|
echo "\t<tr>\n\t\t<th>", $i, "</th>\n";
|
||||||
foreach ($row as $col) {
|
foreach ($row as $col) {
|
||||||
echo "\t\t<td>", htmlSpecialChars($col), "</td>\n";
|
echo "\t\t<td>", htmlSpecialChars((string) $col), "</td>\n";
|
||||||
}
|
}
|
||||||
echo "\t</tr>\n";
|
echo "\t</tr>\n";
|
||||||
}
|
}
|
||||||
@@ -220,11 +220,11 @@ class Helpers
|
|||||||
* @param string alias key
|
* @param string alias key
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function alias(& $config, $key, $alias)
|
public static function alias(&$config, $key, $alias)
|
||||||
{
|
{
|
||||||
$foo = & $config;
|
$foo = &$config;
|
||||||
foreach (explode('|', $key) as $key) {
|
foreach (explode('|', $key) as $key) {
|
||||||
$foo = & $foo[$key];
|
$foo = &$foo[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($foo) && isset($config[$alias])) {
|
if (!isset($foo) && isset($config[$alias])) {
|
||||||
|
@@ -19,10 +19,10 @@ use Dibi\Type;
|
|||||||
* @property-read Table $table
|
* @property-read Table $table
|
||||||
* @property-read string $type
|
* @property-read string $type
|
||||||
* @property-read mixed $nativeType
|
* @property-read mixed $nativeType
|
||||||
* @property-read int $size
|
* @property-read int|NULL $size
|
||||||
* @property-read bool $unsigned
|
* @property-read bool|NULL $unsigned
|
||||||
* @property-read bool $nullable
|
* @property-read bool|NULL $nullable
|
||||||
* @property-read bool $autoIncrement
|
* @property-read bool|NULL $autoIncrement
|
||||||
* @property-read mixed $default
|
* @property-read mixed $default
|
||||||
*/
|
*/
|
||||||
class Column
|
class Column
|
||||||
@@ -83,7 +83,7 @@ class Column
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string|NULL
|
||||||
*/
|
*/
|
||||||
public function getTableName()
|
public function getTableName()
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ class Column
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getNativeType()
|
public function getNativeType()
|
||||||
{
|
{
|
||||||
@@ -110,7 +110,7 @@ class Column
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int|NULL
|
||||||
*/
|
*/
|
||||||
public function getSize()
|
public function getSize()
|
||||||
{
|
{
|
||||||
@@ -119,7 +119,7 @@ class Column
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool|NULL
|
||||||
*/
|
*/
|
||||||
public function isUnsigned()
|
public function isUnsigned()
|
||||||
{
|
{
|
||||||
@@ -128,7 +128,7 @@ class Column
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool|NULL
|
||||||
*/
|
*/
|
||||||
public function isNullable()
|
public function isNullable()
|
||||||
{
|
{
|
||||||
@@ -137,7 +137,7 @@ class Column
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool|NULL
|
||||||
*/
|
*/
|
||||||
public function isAutoIncrement()
|
public function isAutoIncrement()
|
||||||
{
|
{
|
||||||
|
@@ -184,7 +184,7 @@ class Result implements IDataSource
|
|||||||
/**
|
/**
|
||||||
* Fetches the row at current position, process optional type conversion.
|
* Fetches the row at current position, process optional type conversion.
|
||||||
* and moves the internal cursor to the next position
|
* and moves the internal cursor to the next position
|
||||||
* @return Row|FALSE array on success, FALSE if no next record
|
* @return Row|FALSE
|
||||||
*/
|
*/
|
||||||
final public function fetch()
|
final public function fetch()
|
||||||
{
|
{
|
||||||
@@ -271,7 +271,7 @@ class Result implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = NULL;
|
$data = NULL;
|
||||||
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
// check columns
|
// check columns
|
||||||
foreach ($assoc as $as) {
|
foreach ($assoc as $as) {
|
||||||
@@ -291,12 +291,12 @@ class Result implements IDataSource
|
|||||||
|
|
||||||
// make associative tree
|
// make associative tree
|
||||||
do {
|
do {
|
||||||
$x = & $data;
|
$x = &$data;
|
||||||
|
|
||||||
// iterative deepening
|
// iterative deepening
|
||||||
foreach ($assoc as $i => $as) {
|
foreach ($assoc as $i => $as) {
|
||||||
if ($as === '[]') { // indexed-array node
|
if ($as === '[]') { // indexed-array node
|
||||||
$x = & $x[];
|
$x = &$x[];
|
||||||
|
|
||||||
} elseif ($as === '=') { // "value" node
|
} elseif ($as === '=') { // "value" node
|
||||||
$x = $row->{$assoc[$i + 1]};
|
$x = $row->{$assoc[$i + 1]};
|
||||||
@@ -305,14 +305,14 @@ class Result implements IDataSource
|
|||||||
} elseif ($as === '->') { // "object" node
|
} elseif ($as === '->') { // "object" node
|
||||||
if ($x === NULL) {
|
if ($x === NULL) {
|
||||||
$x = clone $row;
|
$x = clone $row;
|
||||||
$x = & $x->{$assoc[$i + 1]};
|
$x = &$x->{$assoc[$i + 1]};
|
||||||
$x = NULL; // prepare child node
|
$x = NULL; // prepare child node
|
||||||
} else {
|
} else {
|
||||||
$x = & $x->{$assoc[$i + 1]};
|
$x = &$x->{$assoc[$i + 1]};
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($as !== '|') { // associative-array node
|
} elseif ($as !== '|') { // associative-array node
|
||||||
$x = & $x[$row->$as];
|
$x = &$x[$row->$as];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,32 +356,32 @@ class Result implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$x = & $data;
|
$x = &$data;
|
||||||
|
|
||||||
foreach ($assoc as $i => $as) {
|
foreach ($assoc as $i => $as) {
|
||||||
if ($as === '#') { // indexed-array node
|
if ($as === '#') { // indexed-array node
|
||||||
$x = & $x[];
|
$x = &$x[];
|
||||||
|
|
||||||
} elseif ($as === '=') { // "record" node
|
} elseif ($as === '=') { // "record" node
|
||||||
if ($x === NULL) {
|
if ($x === NULL) {
|
||||||
$x = $row->toArray();
|
$x = $row->toArray();
|
||||||
$x = & $x[ $assoc[$i + 1] ];
|
$x = &$x[ $assoc[$i + 1] ];
|
||||||
$x = NULL; // prepare child node
|
$x = NULL; // prepare child node
|
||||||
} else {
|
} else {
|
||||||
$x = & $x[ $assoc[$i + 1] ];
|
$x = &$x[ $assoc[$i + 1] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($as === '@') { // "object" node
|
} elseif ($as === '@') { // "object" node
|
||||||
if ($x === NULL) {
|
if ($x === NULL) {
|
||||||
$x = clone $row;
|
$x = clone $row;
|
||||||
$x = & $x->{$assoc[$i + 1]};
|
$x = &$x->{$assoc[$i + 1]};
|
||||||
$x = NULL; // prepare child node
|
$x = NULL; // prepare child node
|
||||||
} else {
|
} else {
|
||||||
$x = & $x->{$assoc[$i + 1]};
|
$x = &$x->{$assoc[$i + 1]};
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // associative-array node
|
} else { // associative-array node
|
||||||
$x = & $x[$row->$as];
|
$x = &$x[$row->$as];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +483,7 @@ class Result implements IDataSource
|
|||||||
* @param array
|
* @param array
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function normalize(array & $row)
|
private function normalize(array &$row)
|
||||||
{
|
{
|
||||||
foreach ($this->types as $key => $type) {
|
foreach ($this->types as $key => $type) {
|
||||||
if (!isset($row[$key])) { // NULL
|
if (!isset($row[$key])) { // NULL
|
||||||
@@ -499,7 +499,7 @@ class Result implements IDataSource
|
|||||||
: $tmp;
|
: $tmp;
|
||||||
|
|
||||||
} elseif ($type === Type::FLOAT) {
|
} elseif ($type === Type::FLOAT) {
|
||||||
$value = ltrim($value, '0');
|
$value = ltrim((string) $value, '0');
|
||||||
$p = strpos($value, '.');
|
$p = strpos($value, '.');
|
||||||
if ($p !== FALSE) {
|
if ($p !== FALSE) {
|
||||||
$value = rtrim(rtrim($value, '0'), '.');
|
$value = rtrim(rtrim($value, '0'), '.');
|
||||||
@@ -558,9 +558,9 @@ class Result implements IDataSource
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets data format.
|
* Sets date format.
|
||||||
* @param string type (use constant Type::*)
|
* @param string
|
||||||
* @param string format
|
* @param string|NULL format
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
final public function setFormat($type, $format)
|
final public function setFormat($type, $format)
|
||||||
@@ -572,7 +572,7 @@ class Result implements IDataSource
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns data format.
|
* Returns data format.
|
||||||
* @return string
|
* @return string|NULL
|
||||||
*/
|
*/
|
||||||
final public function getFormat($type)
|
final public function getFormat($type)
|
||||||
{
|
{
|
||||||
|
@@ -27,7 +27,7 @@ class ResultIterator implements \Iterator, \Countable
|
|||||||
/** @var Result */
|
/** @var Result */
|
||||||
private $result;
|
private $result;
|
||||||
|
|
||||||
/** @var int */
|
/** @var mixed */
|
||||||
private $row;
|
private $row;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
|
@@ -105,7 +105,7 @@ trait Strict
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string method name
|
* @param string method name
|
||||||
* @param callabke
|
* @param callable
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function extensionMethod($name, $callback = NULL)
|
public static function extensionMethod($name, $callback = NULL)
|
||||||
@@ -131,7 +131,7 @@ trait Strict
|
|||||||
|
|
||||||
$list = & self::$extMethods[strtolower($name)];
|
$list = & self::$extMethods[strtolower($name)];
|
||||||
if ($callback === NULL) { // getter
|
if ($callback === NULL) { // getter
|
||||||
$cache = & $list[''][$class];
|
$cache = &$list[''][$class];
|
||||||
if (isset($cache)) {
|
if (isset($cache)) {
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
@@ -73,8 +73,8 @@ final class Translator
|
|||||||
|
|
||||||
$commandIns = NULL;
|
$commandIns = NULL;
|
||||||
$lastArr = NULL;
|
$lastArr = NULL;
|
||||||
$cursor = & $this->cursor;
|
$cursor = &$this->cursor;
|
||||||
$comment = & $this->comment;
|
$comment = &$this->comment;
|
||||||
|
|
||||||
// iterate
|
// iterate
|
||||||
$sql = [];
|
$sql = [];
|
||||||
@@ -246,7 +246,7 @@ final class Translator
|
|||||||
case 'in':// replaces scalar %in modifier!
|
case 'in':// replaces scalar %in modifier!
|
||||||
case 'l': // (val, val, ...)
|
case 'l': // (val, val, ...)
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$pair = explode('%', (string) $k, 2); // split into identifier & modifier
|
||||||
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
||||||
}
|
}
|
||||||
return '(' . (($vx || $modifier === 'l') ? implode(', ', $vx) : 'NULL') . ')';
|
return '(' . (($vx || $modifier === 'l') ? implode(', ', $vx) : 'NULL') . ')';
|
||||||
@@ -316,7 +316,7 @@ final class Translator
|
|||||||
if ($value !== NULL && !is_scalar($value)) { // array is already processed
|
if ($value !== NULL && !is_scalar($value)) { // array is already processed
|
||||||
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
|
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
|
||||||
$modifier = 'SQL';
|
$modifier = 'SQL';
|
||||||
} elseif (($value instanceof \DateTime || $value instanceof \DateTimeInterface) && ($modifier === 'd' || $modifier === 't')) {
|
} elseif (($value instanceof \DateTime || $value instanceof \DateTimeInterface) && ($modifier === 'd' || $modifier === 't' || $modifier === 'dt')) {
|
||||||
// continue
|
// continue
|
||||||
} else {
|
} else {
|
||||||
$type = is_object($value) ? get_class($value) : gettype($value);
|
$type = is_object($value) ? get_class($value) : gettype($value);
|
||||||
@@ -326,7 +326,7 @@ final class Translator
|
|||||||
|
|
||||||
switch ($modifier) {
|
switch ($modifier) {
|
||||||
case 's': // string
|
case 's': // string
|
||||||
return $value === NULL ? 'NULL' : $this->driver->escapeText($value);
|
return $value === NULL ? 'NULL' : $this->driver->escapeText((string) $value);
|
||||||
|
|
||||||
case 'bin':// binary
|
case 'bin':// binary
|
||||||
return $value === NULL ? 'NULL' : $this->driver->escapeBinary($value);
|
return $value === NULL ? 'NULL' : $this->driver->escapeBinary($value);
|
||||||
@@ -336,7 +336,7 @@ final class Translator
|
|||||||
|
|
||||||
case 'sN': // string or NULL
|
case 'sN': // string or NULL
|
||||||
case 'sn':
|
case 'sn':
|
||||||
return $value == '' ? 'NULL' : $this->driver->escapeText($value); // notice two equal signs
|
return $value == '' ? 'NULL' : $this->driver->escapeText((string) $value); // notice two equal signs
|
||||||
|
|
||||||
case 'in': // deprecated
|
case 'in': // deprecated
|
||||||
trigger_error('Modifier %in is deprecated, use %iN.', E_USER_DEPRECATED);
|
trigger_error('Modifier %in is deprecated, use %iN.', E_USER_DEPRECATED);
|
||||||
@@ -480,7 +480,7 @@ final class Translator
|
|||||||
|
|
||||||
|
|
||||||
if (!empty($matches[11])) { // placeholder
|
if (!empty($matches[11])) { // placeholder
|
||||||
$cursor = & $this->cursor;
|
$cursor = &$this->cursor;
|
||||||
|
|
||||||
if ($cursor >= count($this->args)) {
|
if ($cursor >= count($this->args)) {
|
||||||
return $this->errors[] = '**Extra placeholder**';
|
return $this->errors[] = '**Extra placeholder**';
|
||||||
@@ -492,7 +492,7 @@ final class Translator
|
|||||||
|
|
||||||
if (!empty($matches[10])) { // modifier
|
if (!empty($matches[10])) { // modifier
|
||||||
$mod = $matches[10];
|
$mod = $matches[10];
|
||||||
$cursor = & $this->cursor;
|
$cursor = &$this->cursor;
|
||||||
|
|
||||||
if ($cursor >= count($this->args) && $mod !== 'else' && $mod !== 'end') {
|
if ($cursor >= count($this->args) && $mod !== 'else' && $mod !== 'end') {
|
||||||
return $this->errors[] = "**Extra modifier %$mod**";
|
return $this->errors[] = "**Extra modifier %$mod**";
|
||||||
@@ -600,7 +600,7 @@ final class Translator
|
|||||||
{
|
{
|
||||||
$value = $this->connection->substitute($value);
|
$value = $this->connection->substitute($value);
|
||||||
$parts = explode('.', $value);
|
$parts = explode('.', $value);
|
||||||
foreach ($parts as & $v) {
|
foreach ($parts as &$v) {
|
||||||
if ($v !== '*') {
|
if ($v !== '*') {
|
||||||
$v = $this->driver->escapeIdentifier($v);
|
$v = $this->driver->escapeIdentifier($v);
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,8 @@ class dibi
|
|||||||
|
|
||||||
/** version */
|
/** version */
|
||||||
const
|
const
|
||||||
VERSION = '3.0.7',
|
VERSION = '3.0.9',
|
||||||
REVISION = 'released on 2017-01-04';
|
REVISION = 'released on 2018-03-09';
|
||||||
|
|
||||||
/** sorting order */
|
/** sorting order */
|
||||||
const
|
const
|
||||||
@@ -90,7 +90,7 @@ class dibi
|
|||||||
* @return Dibi\Connection
|
* @return Dibi\Connection
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public static function connect($config = [], $name = 0)
|
public static function connect($config = [], $name = '0')
|
||||||
{
|
{
|
||||||
return self::$connection = self::$registry[$name] = new Dibi\Connection($config, $name);
|
return self::$connection = self::$registry[$name] = new Dibi\Connection($config, $name);
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ class dibi
|
|||||||
/**
|
/**
|
||||||
* Generates and executes SQL query - Monostate for Dibi\Connection::query().
|
* Generates and executes SQL query - Monostate for Dibi\Connection::query().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
* @return Dibi\Result|int result set object (if any)
|
* @return Dibi\Result|int result set or number of affected rows
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public static function query($args)
|
public static function query($args)
|
||||||
@@ -180,7 +180,7 @@ class dibi
|
|||||||
/**
|
/**
|
||||||
* Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().
|
* Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
* @return Dibi\Result|int result set object (if any)
|
* @return Dibi\Result|int result set or number of affected rows
|
||||||
*/
|
*/
|
||||||
public static function nativeQuery($sql)
|
public static function nativeQuery($sql)
|
||||||
{
|
{
|
||||||
@@ -241,7 +241,7 @@ class dibi
|
|||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().
|
* Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
* @return string
|
* @return mixed
|
||||||
* @throws Dibi\Exception
|
* @throws Dibi\Exception
|
||||||
*/
|
*/
|
||||||
public static function fetchSingle($args)
|
public static function fetchSingle($args)
|
||||||
@@ -382,7 +382,7 @@ class dibi
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string column name
|
* @param mixed column name
|
||||||
* @return Dibi\Fluent
|
* @return Dibi\Fluent
|
||||||
*/
|
*/
|
||||||
public static function select($args)
|
public static function select($args)
|
||||||
|
@@ -23,7 +23,7 @@ class Exception extends \Exception
|
|||||||
* @param mixed
|
* @param mixed
|
||||||
* @param string SQL command
|
* @param string SQL command
|
||||||
*/
|
*/
|
||||||
public function __construct($message = NULL, $code = 0, $sql = NULL)
|
public function __construct($message = '', $code = 0, $sql = NULL)
|
||||||
{
|
{
|
||||||
parent::__construct($message);
|
parent::__construct($message);
|
||||||
$this->code = $code;
|
$this->code = $code;
|
||||||
|
@@ -30,7 +30,7 @@ interface Driver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function connect(array & $config);
|
function connect(array &$config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
@@ -97,19 +97,39 @@ interface Driver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param string value
|
||||||
* @return string encoded value
|
* @return string encoded value
|
||||||
*/
|
*/
|
||||||
function escapeText($value);
|
function escapeText($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function escapeBinary($value);
|
function escapeBinary($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function escapeIdentifier($value);
|
function escapeIdentifier($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function escapeBool($value);
|
function escapeBool($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function escapeDate($value);
|
function escapeDate($value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTime|\DateTimeInterface|string|int
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function escapeDateTime($value);
|
function escapeDateTime($value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,9 +142,12 @@ interface Driver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
|
* @param string
|
||||||
|
* @param int|NULL
|
||||||
|
* @param int|NULL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function applyLimit(& $sql, $limit, $offset);
|
function applyLimit(&$sql, $limit, $offset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,7 +66,6 @@ spl_autoload_register(function ($class) {
|
|||||||
'Dibi\Translator' => 'Translator.php',
|
'Dibi\Translator' => 'Translator.php',
|
||||||
'Dibi\Type' => 'Type.php',
|
'Dibi\Type' => 'Type.php',
|
||||||
], $old2new = [
|
], $old2new = [
|
||||||
'Dibi' => 'dibi.php',
|
|
||||||
'DibiColumnInfo' => 'Dibi\Reflection\Column',
|
'DibiColumnInfo' => 'Dibi\Reflection\Column',
|
||||||
'DibiConnection' => 'Dibi\Connection',
|
'DibiConnection' => 'Dibi\Connection',
|
||||||
'DibiDatabaseInfo' => 'Dibi\Reflection\Database',
|
'DibiDatabaseInfo' => 'Dibi\Reflection\Database',
|
||||||
|
@@ -73,13 +73,13 @@ system = sqlsrv
|
|||||||
;password = "Password12!"
|
;password = "Password12!"
|
||||||
;system = sqlsrv
|
;system = sqlsrv
|
||||||
|
|
||||||
[sqlsrv 2014]
|
;[sqlsrv 2014]
|
||||||
driver = sqlsrv
|
;driver = sqlsrv
|
||||||
host = "(local)\SQL2014"
|
;host = "(local)\SQL2014"
|
||||||
database = master
|
;database = master
|
||||||
username = sa
|
;username = sa
|
||||||
password = "Password12!"
|
;password = "Password12!"
|
||||||
system = sqlsrv
|
;system = sqlsrv
|
||||||
|
|
||||||
;[sqlsrv 2014-pdo]
|
;[sqlsrv 2014-pdo]
|
||||||
;driver = pdo
|
;driver = pdo
|
||||||
|
@@ -29,7 +29,7 @@ test(function () use ($config) { // lazy
|
|||||||
|
|
||||||
|
|
||||||
test(function () use ($config) { // query string
|
test(function () use ($config) { // query string
|
||||||
$conn = new Connection(http_build_query($config, NULL, '&'));
|
$conn = new Connection(http_build_query($config, '', '&'));
|
||||||
Assert::true($conn->isConnected());
|
Assert::true($conn->isConnected());
|
||||||
|
|
||||||
Assert::null($conn->getConfig('lazy'));
|
Assert::null($conn->getConfig('lazy'));
|
||||||
|
@@ -10,7 +10,7 @@ class MockDriver extends Dibi\Drivers\SqlsrvDriver
|
|||||||
function __construct()
|
function __construct()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
function connect(array & $config)
|
function connect(array &$config)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
function query($sql)
|
function query($sql)
|
||||||
|
@@ -15,7 +15,7 @@ class MockResult extends Dibi\Result
|
|||||||
{
|
{
|
||||||
$normalize = new ReflectionMethod('Dibi\Result', 'normalize');
|
$normalize = new ReflectionMethod('Dibi\Result', 'normalize');
|
||||||
$normalize->setAccessible(TRUE);
|
$normalize->setAccessible(TRUE);
|
||||||
$normalize->invokeArgs($this, [& $row]);
|
$normalize->invokeArgs($this, [&$row]);
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user