mirror of
https://github.com/dg/dibi.git
synced 2025-09-03 02:52:47 +02:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c8457ab58a | ||
|
cb0cf4ba2f | ||
|
8e7df8374b | ||
|
848ac76fed | ||
|
a0f2ca2fca | ||
|
cf14987b42 | ||
|
01c7ab63e3 | ||
|
520119740d | ||
|
7fa05f381b | ||
|
3a962de553 | ||
|
96e370b8fe | ||
|
ec0455ae00 | ||
|
b61737311e |
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -1,8 +1,8 @@
|
|||||||
.gitattributes export-ignore
|
.gitattributes export-ignore
|
||||||
.gitignore export-ignore
|
.gitignore export-ignore
|
||||||
.github export-ignore
|
.github export-ignore
|
||||||
.travis.yml export-ignore
|
appveyor.yml export-ignore
|
||||||
ecs.php export-ignore
|
ncs.* export-ignore
|
||||||
phpstan.neon export-ignore
|
phpstan.neon export-ignore
|
||||||
tests/ export-ignore
|
tests/ export-ignore
|
||||||
|
|
||||||
|
6
.github/workflows/coding-style.yml
vendored
6
.github/workflows/coding-style.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
|||||||
name: Nette Code Checker
|
name: Nette Code Checker
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: shivammathur/setup-php@v2
|
- uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: 8.0
|
php-version: 8.0
|
||||||
@@ -21,11 +21,11 @@ jobs:
|
|||||||
name: Nette Coding Standard
|
name: Nette Coding Standard
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: shivammathur/setup-php@v2
|
- uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: 8.0
|
php-version: 8.0
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress --ignore-platform-reqs
|
- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress
|
||||||
- run: php temp/coding-standard/ecs check
|
- run: php temp/coding-standard/ecs check
|
||||||
|
2
.github/workflows/static-analysis.yml
vendored
2
.github/workflows/static-analysis.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
name: PHPStan
|
name: PHPStan
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: shivammathur/setup-php@v2
|
- uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: 8.0
|
php-version: 8.0
|
||||||
|
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
|
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
|
||||||
|
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ jobs:
|
|||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: shivammathur/setup-php@v2
|
- uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php }}
|
php-version: ${{ matrix.php }}
|
||||||
@@ -106,7 +106,7 @@ jobs:
|
|||||||
- run: composer install --no-progress --prefer-dist
|
- run: composer install --no-progress --prefer-dist
|
||||||
- run: vendor/bin/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src
|
- run: vendor/bin/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src
|
||||||
- if: failure()
|
- if: failure()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: output
|
name: output
|
||||||
path: tests/**/output
|
path: tests/**/output
|
||||||
|
@@ -34,7 +34,7 @@ Install Dibi via Composer:
|
|||||||
composer require dibi/dibi
|
composer require dibi/dibi
|
||||||
```
|
```
|
||||||
|
|
||||||
The Dibi 4.2 requires PHP version 7.2 and supports PHP up to 8.1.
|
The Dibi 4.2 requires PHP version 7.2 and supports PHP up to 8.3.
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
@@ -341,7 +341,7 @@ $database->query('INSERT INTO users', [
|
|||||||
There are three methods for dealing with transactions:
|
There are three methods for dealing with transactions:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$database->beginTransaction();
|
$database->begin();
|
||||||
|
|
||||||
$database->commit();
|
$database->commit();
|
||||||
|
|
||||||
|
@@ -159,7 +159,7 @@ class Panel implements Tracy\IBarPanel
|
|||||||
return '<style> #tracy-debug td.tracy-DibiProfiler-sql { background: white !important }
|
return '<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:\u{a0}' . count($this->events)
|
<h1>Queries:' . "\u{a0}" . count($this->events)
|
||||||
. ($totalTime === null ? '' : ", time:\u{a0}" . number_format($totalTime * 1000, 1, '.', "\u{202f}") . "\u{202f}ms") . ', '
|
. ($totalTime === null ? '' : ", time:\u{a0}" . number_format($totalTime * 1000, 1, '.', "\u{202f}") . "\u{202f}ms") . ', '
|
||||||
. htmlspecialchars($this->getConnectionName($singleConnection)) . '</h1>
|
. htmlspecialchars($this->getConnectionName($singleConnection)) . '</h1>
|
||||||
<div class="tracy-inner tracy-DibiProfiler">
|
<div class="tracy-inner tracy-DibiProfiler">
|
||||||
|
@@ -23,9 +23,6 @@ class FirebirdResult implements Dibi\ResultDriver
|
|||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $resultSet
|
* @param resource $resultSet
|
||||||
@@ -36,17 +33,6 @@ class FirebirdResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
*/
|
*/
|
||||||
@@ -105,7 +91,6 @@ class FirebirdResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return is_resource($this->resultSet) ? $this->resultSet : null;
|
return is_resource($this->resultSet) ? $this->resultSet : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,6 @@ class MySqliResult implements Dibi\ResultDriver
|
|||||||
/** @var \mysqli_result */
|
/** @var \mysqli_result */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
/** @var bool Is buffered (seekable and countable)? */
|
/** @var bool Is buffered (seekable and countable)? */
|
||||||
private $buffered;
|
private $buffered;
|
||||||
|
|
||||||
@@ -36,17 +33,6 @@ class MySqliResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
@$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
*/
|
*/
|
||||||
@@ -136,7 +122,6 @@ class MySqliResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource(): \mysqli_result
|
public function getResultResource(): \mysqli_result
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return $this->resultSet;
|
return $this->resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,6 @@ class OdbcResult implements Dibi\ResultDriver
|
|||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
/** @var int Cursor */
|
/** @var int Cursor */
|
||||||
private $row = 0;
|
private $row = 0;
|
||||||
|
|
||||||
@@ -38,17 +35,6 @@ class OdbcResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
*/
|
*/
|
||||||
@@ -129,7 +115,6 @@ class OdbcResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return is_resource($this->resultSet) ? $this->resultSet : null;
|
return is_resource($this->resultSet) ? $this->resultSet : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,6 @@ class OracleResult implements Dibi\ResultDriver
|
|||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $resultSet
|
* @param resource $resultSet
|
||||||
@@ -35,17 +32,6 @@ class OracleResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
*/
|
*/
|
||||||
@@ -111,7 +97,6 @@ class OracleResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return is_resource($this->resultSet) ? $this->resultSet : null;
|
return is_resource($this->resultSet) ? $this->resultSet : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,9 +24,6 @@ class PostgreResult implements Dibi\ResultDriver
|
|||||||
/** @var resource|PgSql\Result */
|
/** @var resource|PgSql\Result */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource|PgSql\Result $resultSet
|
* @param resource|PgSql\Result $resultSet
|
||||||
@@ -37,17 +34,6 @@ class PostgreResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +100,6 @@ class PostgreResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return is_resource($this->resultSet) || $this->resultSet instanceof PgSql\Result
|
return is_resource($this->resultSet) || $this->resultSet instanceof PgSql\Result
|
||||||
? $this->resultSet
|
? $this->resultSet
|
||||||
: null;
|
: null;
|
||||||
|
@@ -292,7 +292,8 @@ class SqliteDriver implements Dibi\Driver
|
|||||||
callable $rowCallback,
|
callable $rowCallback,
|
||||||
callable $agrCallback,
|
callable $agrCallback,
|
||||||
int $numArgs = -1
|
int $numArgs = -1
|
||||||
): void {
|
): void
|
||||||
|
{
|
||||||
$this->connection->createAggregate($name, $rowCallback, $agrCallback, $numArgs);
|
$this->connection->createAggregate($name, $rowCallback, $agrCallback, $numArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,9 +23,6 @@ class SqliteResult implements Dibi\ResultDriver
|
|||||||
/** @var \SQLite3Result */
|
/** @var \SQLite3Result */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(\SQLite3Result $resultSet)
|
public function __construct(\SQLite3Result $resultSet)
|
||||||
{
|
{
|
||||||
@@ -33,17 +30,6 @@ class SqliteResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
@$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @throws Dibi\NotSupportedException
|
* @throws Dibi\NotSupportedException
|
||||||
@@ -109,7 +95,6 @@ class SqliteResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource(): \SQLite3Result
|
public function getResultResource(): \SQLite3Result
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return $this->resultSet;
|
return $this->resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,6 @@ class SqlsrvResult implements Dibi\ResultDriver
|
|||||||
/** @var resource */
|
/** @var resource */
|
||||||
private $resultSet;
|
private $resultSet;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $autoFree = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $resultSet
|
* @param resource $resultSet
|
||||||
@@ -35,17 +32,6 @@ class SqlsrvResult implements Dibi\ResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically frees the resources allocated for this result set.
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
if ($this->autoFree && $this->getResultResource()) {
|
|
||||||
$this->free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
*/
|
*/
|
||||||
@@ -107,7 +93,6 @@ class SqlsrvResult implements Dibi\ResultDriver
|
|||||||
*/
|
*/
|
||||||
public function getResultResource()
|
public function getResultResource()
|
||||||
{
|
{
|
||||||
$this->autoFree = false;
|
|
||||||
return is_resource($this->resultSet) ? $this->resultSet : null;
|
return is_resource($this->resultSet) ? $this->resultSet : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,11 @@ class Event
|
|||||||
|
|
||||||
$dibiDir = dirname((new \ReflectionClass('dibi'))->getFileName()) . DIRECTORY_SEPARATOR;
|
$dibiDir = dirname((new \ReflectionClass('dibi'))->getFileName()) . DIRECTORY_SEPARATOR;
|
||||||
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $row) {
|
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $row) {
|
||||||
if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], $dibiDir) !== 0) {
|
if (
|
||||||
|
isset($row['file'])
|
||||||
|
&& preg_match('~\.(php.?|phtml)$~', $row['file'])
|
||||||
|
&& substr($row['file'], 0, strlen($dibiDir)) !== $dibiDir
|
||||||
|
) {
|
||||||
$this->source = [$row['file'], (int) $row['line']];
|
$this->source = [$row['file'], (int) $row['line']];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@ namespace Dibi;
|
|||||||
* @method Fluent innerJoin(...$table)
|
* @method Fluent innerJoin(...$table)
|
||||||
* @method Fluent rightJoin(...$table)
|
* @method Fluent rightJoin(...$table)
|
||||||
* @method Fluent outerJoin(...$table)
|
* @method Fluent outerJoin(...$table)
|
||||||
|
* @method Fluent union(Fluent $fluent)
|
||||||
|
* @method Fluent unionAll(Fluent $fluent)
|
||||||
* @method Fluent as(...$field)
|
* @method Fluent as(...$field)
|
||||||
* @method Fluent on(...$cond)
|
* @method Fluent on(...$cond)
|
||||||
* @method Fluent and(...$cond)
|
* @method Fluent and(...$cond)
|
||||||
|
@@ -14,6 +14,7 @@ namespace Dibi;
|
|||||||
* Lazy cached storage.
|
* Lazy cached storage.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
abstract class HashMapBase
|
abstract class HashMapBase
|
||||||
{
|
{
|
||||||
/** @var callable */
|
/** @var callable */
|
||||||
|
@@ -44,22 +44,22 @@ class ResultIterator implements \Iterator, \Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[\ReturnTypeWillChange]
|
|
||||||
/**
|
/**
|
||||||
* Returns the key of the current element.
|
* Returns the key of the current element.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function key()
|
public function key()
|
||||||
{
|
{
|
||||||
return $this->pointer;
|
return $this->pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[\ReturnTypeWillChange]
|
|
||||||
/**
|
/**
|
||||||
* Returns the current element.
|
* Returns the current element.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
||||||
return $this->row;
|
return $this->row;
|
||||||
|
@@ -13,6 +13,7 @@ namespace Dibi;
|
|||||||
/**
|
/**
|
||||||
* Result set single row.
|
* Result set single row.
|
||||||
*/
|
*/
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||||
{
|
{
|
||||||
public function __construct(array $arr)
|
public function __construct(array $arr)
|
||||||
@@ -48,6 +49,9 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function __get(string $key)
|
public function __get(string $key)
|
||||||
{
|
{
|
||||||
$hint = Helpers::getSuggestion(array_keys((array) $this), $key);
|
$hint = Helpers::getSuggestion(array_keys((array) $this), $key);
|
||||||
|
@@ -109,7 +109,7 @@ final class Translator
|
|||||||
(\?) ## 11) placeholder
|
(\?) ## 11) placeholder
|
||||||
)/xs
|
)/xs
|
||||||
XX
|
XX
|
||||||
,
|
,
|
||||||
[$this, 'cb'],
|
[$this, 'cb'],
|
||||||
substr($arg, $toSkip)
|
substr($arg, $toSkip)
|
||||||
);
|
);
|
||||||
@@ -448,7 +448,7 @@ XX
|
|||||||
:(\S*?:)([a-zA-Z0-9._]?)
|
:(\S*?:)([a-zA-Z0-9._]?)
|
||||||
)/sx
|
)/sx
|
||||||
XX
|
XX
|
||||||
,
|
,
|
||||||
[$this, 'cb'],
|
[$this, 'cb'],
|
||||||
substr($value, $toSkip)
|
substr($value, $toSkip)
|
||||||
);
|
);
|
||||||
|
@@ -44,8 +44,7 @@ class dibi
|
|||||||
IDENTIFIER = 'n';
|
IDENTIFIER = 'n';
|
||||||
|
|
||||||
/** version */
|
/** version */
|
||||||
public const
|
public const VERSION = '4.2.8';
|
||||||
VERSION = '4.2.6';
|
|
||||||
|
|
||||||
/** sorting order */
|
/** sorting order */
|
||||||
public const
|
public const
|
||||||
|
21
tests/dibi/Event.source.phpt
Normal file
21
tests/dibi/Event.source.phpt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Tester\Assert;
|
||||||
|
|
||||||
|
require __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
|
|
||||||
|
$conn = new Dibi\Connection($config);
|
||||||
|
|
||||||
|
$event = new Dibi\Event($conn, Dibi\Event::CONNECT);
|
||||||
|
Assert::same([__FILE__, __LINE__ - 1], $event->source);
|
||||||
|
|
||||||
|
eval('$event = new Dibi\Event($conn, Dibi\Event::CONNECT);');
|
||||||
|
Assert::same([__FILE__, __LINE__ - 1], $event->source);
|
||||||
|
|
||||||
|
array_map(function () use ($conn) {
|
||||||
|
$event = new Dibi\Event($conn, Dibi\Event::CONNECT);
|
||||||
|
Assert::same([__FILE__, __LINE__ - 1], $event->source);
|
||||||
|
}, [null]);
|
@@ -82,10 +82,9 @@ $tests = function ($conn) {
|
|||||||
$conn->translate('SELECT 1 %lmt', -10)
|
$conn->translate('SELECT 1 %lmt', -10)
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert::exception(
|
Assert::exception(function () {
|
||||||
$conn->translate('SELECT 1 %ofs %lmt', 10, 10),
|
$conn->translate('SELECT 1 %ofs %lmt', 10, 10);
|
||||||
Dibi\NotSupportedException::class
|
}, Dibi\NotSupportedException::class);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ function test(string $title, Closure $function): void
|
|||||||
/** Replaces [] with driver-specific quotes */
|
/** Replaces [] with driver-specific quotes */
|
||||||
function reformat($s)
|
function reformat($s)
|
||||||
{
|
{
|
||||||
global $config;
|
$config = $GLOBALS['config'];
|
||||||
if (is_array($s)) {
|
if (is_array($s)) {
|
||||||
if (isset($s[$config['system']])) {
|
if (isset($s[$config['system']])) {
|
||||||
return $s[$config['system']];
|
return $s[$config['system']];
|
||||||
@@ -72,7 +72,7 @@ function reformat($s)
|
|||||||
|
|
||||||
function num($n)
|
function num($n)
|
||||||
{
|
{
|
||||||
global $config;
|
$config = $GLOBALS['config'];
|
||||||
if (substr($config['dsn'] ?? '', 0, 5) === 'odbc:') {
|
if (substr($config['dsn'] ?? '', 0, 5) === 'odbc:') {
|
||||||
$n = is_float($n) ? "$n.0" : (string) $n;
|
$n = is_float($n) ? "$n.0" : (string) $n;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user