mirror of
https://github.com/dg/dibi.git
synced 2025-09-01 18:12:51 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
22e6ea4e40 | ||
|
f0d2c3f414 | ||
|
873ed3115d | ||
|
73289d0569 | ||
|
7b899ddda5 | ||
|
8860268791 | ||
|
551b576271 | ||
|
74d0a78ec2 | ||
|
be7c3f095d | ||
|
3a6dc07da8 | ||
|
9b070bb737 | ||
|
917971992f | ||
|
bc564555f8 | ||
|
3e20a6b8fc | ||
|
c019e7cac2 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,4 +1,5 @@
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.github export-ignore
|
||||
.travis.yml export-ignore
|
||||
tests/ export-ignore
|
||||
|
16
.github/issue_template.md
vendored
Normal file
16
.github/issue_template.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
- bug report? yes/no
|
||||
- feature request? yes/no
|
||||
- version: ?.?.? <!-- exact release version, for bug reports -->
|
||||
|
||||
### Description
|
||||
...
|
||||
|
||||
### Steps To Reproduce
|
||||
... If possible a minimal demo of the problem ...
|
||||
|
||||
<!--
|
||||
REMEMBER, AN ISSUE IS NOT THE PLACE TO ASK QUESTIONS. We will be happy to help you on Gitter https://gitter.im/nette/nette
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report.
|
||||
Feature requests are welcome. Explain your intentions. It's up to you to make a strong case to convince the project's developers of the merits of this feature.
|
||||
-->
|
11
.github/pull_request_template.md
vendored
Normal file
11
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
- bug fix? yes/no <!-- #issue numbers, if any -->
|
||||
- new feature? yes/no
|
||||
- BC break? yes/no
|
||||
|
||||
<!--
|
||||
Describe your changes here to communicate to the maintainers why we should accept this pull request.
|
||||
|
||||
Please add new tests to show the fix or feature works.
|
||||
|
||||
Thanks for contributing!
|
||||
-->
|
@@ -9,7 +9,6 @@ php:
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: 7.1
|
||||
- php: hhvm
|
||||
|
||||
script:
|
||||
|
@@ -1,27 +1,31 @@
|
||||
How to contribute & use the issue tracker
|
||||
=========================================
|
||||
|
||||
The issue tracker is the preferred channel for bug reports, features requests
|
||||
and submitting pull requests, but please respect the following restrictions:
|
||||
Dibi welcomes your contributions. There are several ways to help out:
|
||||
|
||||
* Please **do not** use the issue tracker for personal support requests (use
|
||||
[dibi forum](https://forum.dibiphp.com) or [Stack Overflow](http://stackoverflow.com)).
|
||||
* Create an issue on GitHub, if you have found a bug
|
||||
* Write test cases for open bug issues
|
||||
* Write fixes for open bug/feature issues, preferably with test cases included
|
||||
* Contribute to the documentation
|
||||
|
||||
* Please **do not** derail or troll issues. Keep the discussion on topic and
|
||||
respect the opinions of others.
|
||||
Issues
|
||||
------
|
||||
|
||||
* Use the GitHub **issue search** — check if the issue has already been
|
||||
reported.
|
||||
Please **do not use the issue tracker to ask questions**. We will be happy to help you
|
||||
on [Dibi forum](https://forum.dibiphp.com).
|
||||
|
||||
A good **bug report** shouldn't leave others needing to chase you up for more
|
||||
A good bug report shouldn't leave others needing to chase you up for more
|
||||
information. Please try to be as detailed as possible in your report.
|
||||
|
||||
**Feature requests** are welcome. But take a moment to find out whether your idea
|
||||
fits with the scope and aims of the project. It's up to *you* to make a strong
|
||||
case to convince the project's developers of the merits of this feature.
|
||||
|
||||
We welcome **pull requests**. If you'd like to contribute, please take a moment
|
||||
to [read the guidelines](https://nette.org/en/contributing) in order to make
|
||||
the contribution process easy and effective for everyone involved.
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Thanks!
|
||||
The best way to propose a feature is to discuss your ideas on [Dibi forum](https://forum.dibiphp.com) before implementing them.
|
||||
|
||||
Please do not fix whitespace, format code, or make a purely cosmetic patch.
|
||||
|
||||
Thanks! :heart:
|
||||
|
@@ -110,7 +110,7 @@ class Panel implements Tracy\IBarPanel
|
||||
$backup = [$event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
|
||||
$event->connection->onEvent = NULL;
|
||||
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
|
||||
$explain = Helpers::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
|
||||
$explain = Helpers::dump(@$event->connection->nativeQuery("$cmd $event->sql"), TRUE);
|
||||
} catch (Dibi\Exception $e) {
|
||||
}
|
||||
list($event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
|
||||
|
@@ -289,7 +289,7 @@ class Connection
|
||||
* @param array
|
||||
* @return string
|
||||
*/
|
||||
private function translateArgs($args)
|
||||
protected function translateArgs($args)
|
||||
{
|
||||
$this->connected || $this->connect();
|
||||
if (!$this->translator) {
|
||||
@@ -555,7 +555,7 @@ class Connection
|
||||
/**
|
||||
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
||||
* @param array|mixed one or more arguments
|
||||
* @return Row
|
||||
* @return Row|bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fetch($args)
|
||||
@@ -581,7 +581,7 @@ class Connection
|
||||
/**
|
||||
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
|
||||
* @param array|mixed one or more arguments
|
||||
* @return string
|
||||
* @return string|bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fetchSingle($args)
|
||||
@@ -594,7 +594,7 @@ class Connection
|
||||
/**
|
||||
* Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
|
||||
* @param array|mixed one or more arguments
|
||||
* @return string
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fetchPairs($args)
|
||||
|
@@ -58,13 +58,14 @@ class DateTime extends \DateTime
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
if (isset($this->fix)) {
|
||||
if (isset($this->fix[1])) {
|
||||
$this->__construct($this->fix[0], new \DateTimeZone($this->fix[1]));
|
||||
} else {
|
||||
$this->__construct($this->fix[0]);
|
||||
}
|
||||
if (isset($this->fix, $this->fix[1])) {
|
||||
$this->__construct($this->fix[0], new \DateTimeZone($this->fix[1]));
|
||||
unset($this->fix);
|
||||
} elseif (isset($this->fix)) {
|
||||
$this->__construct($this->fix[0]);
|
||||
unset($this->fix);
|
||||
} else {
|
||||
parent::__wakeup();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -78,9 +78,9 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
];
|
||||
|
||||
if (empty($config['persistent'])) {
|
||||
$this->connection = ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @
|
||||
$this->connection = @ibase_connect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @
|
||||
} else {
|
||||
$this->connection = ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @
|
||||
$this->connection = @ibase_pconnect($config['database'], $config['username'], $config['password'], $config['charset'], $config['buffers']); // intentionally @
|
||||
}
|
||||
|
||||
if (!is_resource($this->connection)) {
|
||||
@@ -370,7 +370,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function fetch($assoc)
|
||||
{
|
||||
$result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @
|
||||
$result = $assoc ? @ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : @ibase_fetch_row($this->resultSet, IBASE_TEXT); // intentionally @
|
||||
|
||||
if (ibase_errcode()) {
|
||||
if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
|
||||
@@ -378,7 +378,7 @@ class FirebirdDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
throw new Dibi\ProcedureException($match[3], $match[1], $match[2]);
|
||||
|
||||
} else {
|
||||
throw new Dibi\DriverException($msg, ibase_errcode());
|
||||
throw new Dibi\DriverException(ibase_errmsg(), ibase_errcode());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -466,7 +466,20 @@ class OracleDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
*/
|
||||
public function getColumns($table)
|
||||
{
|
||||
throw new Dibi\NotImplementedException;
|
||||
$res = $this->query('SELECT * FROM "ALL_TAB_COLUMNS" WHERE "TABLE_NAME" = ' . $this->escapeText($table));
|
||||
$columns = [];
|
||||
while ($row = $res->fetch(TRUE)) {
|
||||
$columns[] = [
|
||||
'table' => $row['TABLE_NAME'],
|
||||
'name' => $row['COLUMN_NAME'],
|
||||
'nativetype' => $row['DATA_TYPE'],
|
||||
'size' => isset($row['DATA_LENGTH']) ? $row['DATA_LENGTH'] : NULL,
|
||||
'nullable' => $row['NULLABLE'] === 'Y',
|
||||
'default' => $row['DATA_DEFAULT'],
|
||||
'vendor' => $row,
|
||||
];
|
||||
}
|
||||
return $columns;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -100,7 +100,7 @@ class PostgreDriver implements Dibi\Driver, Dibi\ResultDriver, Dibi\Reflector
|
||||
}
|
||||
|
||||
if (isset($config['schema'])) {
|
||||
$this->query('SET search_path TO "' . $config['schema'] . '"');
|
||||
$this->query('SET search_path TO "' . implode('", "', (array) $config['schema']) . '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -515,7 +515,7 @@ class Result implements IDataSource
|
||||
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
|
||||
|
||||
} elseif ($type === Type::DATETIME || $type === Type::DATE || $type === Type::TIME) {
|
||||
if ((int) $value !== 0 || substr((string) $value, 0, 3) === '00:') { // '', NULL, FALSE, '0000-00-00', ...
|
||||
if ($value && substr((string) $value, 0, 3) !== '000') { // '', NULL, FALSE, '0000-00-00', ...
|
||||
$value = new DateTime($value);
|
||||
$row[$key] = empty($this->formats[$type]) ? $value : $value->format($this->formats[$type]);
|
||||
} else {
|
||||
|
@@ -38,7 +38,7 @@ class Row implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
{
|
||||
$time = $this[$key];
|
||||
if (!$time instanceof DateTime) {
|
||||
if ((int) $time === 0 && substr((string) $time, 0, 3) !== '00:') { // '', NULL, FALSE, '0000-00-00', ...
|
||||
if (!$time || substr((string) $time, 0, 3) === '000') { // '', NULL, FALSE, '0000-00-00', ...
|
||||
return NULL;
|
||||
}
|
||||
$time = new DateTime($time);
|
||||
|
@@ -22,8 +22,8 @@ class dibi
|
||||
|
||||
/** version */
|
||||
const
|
||||
VERSION = '3.0.5',
|
||||
REVISION = 'released on 2016-07-20';
|
||||
VERSION = '3.0.7',
|
||||
REVISION = 'released on 2017-01-04';
|
||||
|
||||
/** sorting order */
|
||||
const
|
||||
@@ -254,7 +254,7 @@ class dibi
|
||||
/**
|
||||
* Executes SQL query and fetch pairs - Monostate for Dibi\Connection::query() & fetchPairs().
|
||||
* @param array|mixed one or more arguments
|
||||
* @return string
|
||||
* @return array
|
||||
* @throws Dibi\Exception
|
||||
*/
|
||||
public static function fetchPairs($args)
|
||||
|
@@ -139,7 +139,7 @@ test(function () {
|
||||
Assert::same(['col' => 1], $result->test(['col' => TRUE]));
|
||||
Assert::same(['col' => 0], $result->test(['col' => FALSE]));
|
||||
|
||||
Assert::same(['col' => 0], $result->test(['col' => '']));
|
||||
Assert::same(['col' => 0], @$result->test(['col' => ''])); // triggers warning in PHP 7.1
|
||||
Assert::same(['col' => 0], $result->test(['col' => '0']));
|
||||
Assert::same(['col' => 1], $result->test(['col' => '1']));
|
||||
Assert::same(['col' => 10], $result->test(['col' => '10']));
|
||||
|
@@ -522,7 +522,7 @@ Assert::same(
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT INTO 0'),
|
||||
$conn->translate('INSERT INTO %f', 'ahoj')
|
||||
@$conn->translate('INSERT INTO %f', 'ahoj') // triggers warning in PHP 7.1
|
||||
);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user