1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-30 09:19:48 +02:00

Compare commits

...

21 Commits

Author SHA1 Message Date
David Grudl
17df4d17fb Released version 2.2.5
This release marks the end of life of 2.2 series.
2015-10-26 19:33:34 +01:00
David Grudl
51adcd98e0 DibiFluent::fetch() uses limit only when there is no LIMIT & OFFSET (fixes 20f2093 on MSSQL) 2015-10-26 16:46:20 +01:00
David Grudl
aaa5abd4b6 DibiFluent: prevents doubled processing 2015-10-26 16:45:58 +01:00
David Grudl
e4acc4a2c8 DibiTranslator: removed die() 2015-10-26 16:45:21 +01:00
David Grudl
0a2d12c47a Released version 2.2.4
This release marks the end of life of 2.2 series.
2015-10-22 02:50:29 +02:00
David Grudl
19748f7c5b Result: improved normalization of int 2015-10-13 15:16:56 +02:00
David Grudl
ee5f1dd293 Result: fixed normalization of float when ends with "0" [Closes #189] 2015-10-13 15:16:54 +02:00
castamir
f4ae1e692f DibiFluent::fetch(): fixed limit clause duplication [Closes #188][Closes #186][Closes #185] 2015-10-09 12:02:02 +02:00
David Grudl
443661f0e9 DibiFluent: removed keyword AS from SQL [Closes #172] 2015-10-09 12:01:40 +02:00
David Grudl
ac0ab9041b DibiObject: fixed compatibility with PHP 7 2015-10-09 12:01:03 +02:00
David Grudl
d7885921e6 removed rarely used @property 2015-10-09 12:01:03 +02:00
David Grudl
ce459f440a improved coding style
# Conflicts:
#	dibi/bridges/Tracy/Panel.php
#	dibi/drivers/DibiPdoDriver.php
#	dibi/drivers/DibiPostgreDriver.php
#	tests/dibi/DataSource.phpt
#	tests/dibi/DibiConnection.connect.phpt
#	tests/dibi/DibiConnection.transactions.phpt
#	tests/dibi/DibiFluent.cloning.phpt
#	tests/dibi/DibiFluent.insert.phpt
#	tests/dibi/DibiFluent.select.phpt
#	tests/dibi/DibiFluent.update.phpt
#	tests/dibi/DibiTranslator.conditions.phpt
#	tests/dibi/DibiTranslator.phpt
#	tests/dibi/PdoMssql.limits.phpt
#	tests/dibi/Postgre.like.phpt
2015-10-09 12:01:02 +02:00
David Grudl
df37a500fa used https 2015-10-05 16:16:31 +02:00
Miloslav Hůla
8a5eddfabc Postgre: fixed %like escaping [Closes #159] 2015-01-25 17:26:08 +01:00
David Grudl
a57f3dfc83 Released version 2.2.3 2015-01-13 06:07:08 +01:00
David Grudl
2702de6ccb composer.json: removed branch alias 2015-01-13 06:06:10 +01:00
David Grudl
73e1f366d4 removed tests 2015-01-13 06:05:14 +01:00
MartyIX
656cbfc40c DibiFluent: add leftJoin and on to phpdoc. 2015-01-13 06:02:58 +01:00
Petr BAGR Smrkovský
e778096641 DibiResult: float detection locale fix [Closes #154] 2015-01-13 06:01:54 +01:00
David Grudl
68521d69e3 * .travis: added code checker 2015-01-13 06:01:54 +01:00
David Grudl
a68886f51d examples: improved Tracy examples 2015-01-13 06:01:54 +01:00
76 changed files with 372 additions and 610 deletions

2
.gitattributes vendored
View File

@@ -1,4 +1,2 @@
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
tests/ export-ignore

View File

@@ -1,21 +0,0 @@
language: php
php:
- 5.3.3
- 5.4
- 5.5
- 5.6
- hhvm
matrix:
allow_failures:
- php: hhvm
script: vendor/bin/tester tests -s -c tests/php-unix.ini
after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
before_script:
# Install Nette Tester
- composer install --no-interaction --dev --prefer-source

View File

@@ -7,25 +7,19 @@
"authors": [
{
"name": "David Grudl",
"homepage": "http://davidgrudl.com"
"homepage": "https://davidgrudl.com"
}
],
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"tracy/tracy": "~2.2",
"nette/tester": "~1.1"
"tracy/tracy": "~2.2"
},
"replace": {
"dg/dibi": "self.version"
},
"autoload": {
"classmap": ["dibi/"]
},
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
}
}

View File

@@ -3,7 +3,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
*
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -124,7 +124,8 @@ class DibiNettePanel extends DibiObject implements IBarPanel
$event->connection->onEvent = NULL;
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN' : 'EXPLAIN');
$explain = dibi::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
} catch (DibiException $e) {}
} catch (DibiException $e) {
}
list($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime) = $backup;
}

View File

@@ -2,13 +2,13 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
namespace Dibi\Bridges\Nette;
use dibi,
Nette;
use dibi;
use Nette;
/**

View File

@@ -2,18 +2,18 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
namespace Dibi\Bridges\Tracy;
use dibi,
Tracy;
use dibi;
use Tracy;
/**
* Dibi panel for Tracy.
*
* @package dibi\nette
* @author David Grudl
*/
class Panel extends \DibiObject implements Tracy\IBarPanel
@@ -108,7 +108,8 @@ class Panel extends \DibiObject implements Tracy\IBarPanel
$event->connection->onEvent = NULL;
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN' : 'EXPLAIN');
$explain = dibi::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
} catch (\DibiException $e) {}
} catch (\DibiException $e) {
}
list($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime) = $backup;
}

View File

@@ -3,7 +3,7 @@
/**
* dibi - smart database abstraction layer (http://dibiphp.com)
*
* Copyright (c) 2005, 2012 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005, 2012 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -88,7 +88,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
throw new DibiDriverException(ibase_errmsg(), ibase_errcode());
}
}
}
@@ -349,7 +348,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
*/
public function getRowCount()
{
throw new DibiNotSupportedException("Firebird/Interbase do not support returning number of rows in result set.");
throw new DibiNotSupportedException('Firebird/Interbase do not support returning number of rows in result set.');
}
@@ -379,13 +378,13 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
* @throws DibiException
*/
public function seek($row)
{
throw new DibiNotSupportedException("Firebird/Interbase do not support seek in result set.");
throw new DibiNotSupportedException('Firebird/Interbase do not support seek in result set.');
}
@@ -656,7 +655,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
END AS TRIGGER_ENABLED
FROM RDB\$TRIGGERS
WHERE RDB\$SYSTEM_FLAG = 0"
. ($table === NULL ? ";" : " AND RDB\$RELATION_NAME = UPPER('$table');")
. ($table === NULL ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table');")
);
$triggers = array();
while ($row = $res->fetch(TRUE)) {
@@ -683,7 +682,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
$q = "SELECT TRIM(RDB\$TRIGGER_NAME)
FROM RDB\$TRIGGERS
WHERE RDB\$SYSTEM_FLAG = 0";
$q .= $table === NULL ? ";" : " AND RDB\$RELATION_NAME = UPPER('$table')";
$q .= $table === NULL ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table')";
$res = $this->query($q);
$triggers = array();

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -17,7 +17,7 @@ require_once dirname(__FILE__) . '/DibiMsSql2005Reflector.php';
* - username (or user)
* - password (or pass)
* - database => the database name to select
* - options (array) => connection options {@link http://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx}
* - options (array) => connection options {@link https://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx}
* - charset => character encoding to set (default is UTF-8)
* - resource (resource) => existing connection resource
* - lazy, profiler, result, substitutes, ... => see DibiConnection options
@@ -226,7 +226,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
return "'" . str_replace("'", "''", $value) . "'";
case dibi::IDENTIFIER:
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
return '[' . str_replace(']', ']]', $value) . ']';
case dibi::BOOL:
@@ -327,8 +327,8 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
*/
public function seek($row)
{

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -104,7 +104,7 @@ class DibiMsSql2005Reflector extends DibiObject implements IDibiReflector
{
$keyUsagesRes = $this->driver->query("SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = {$this->driver->escape($table, dibi::TEXT)}");
$keyUsages = array();
while( $row = $keyUsagesRes->fetch(TRUE) ) {
while ($row = $keyUsagesRes->fetch(TRUE)) {
$keyUsages[$row['CONSTRAINT_NAME']][(int) $row['ORDINAL_POSITION'] - 1] = $row['COLUMN_NAME'];
}

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
require_once dirname(__FILE__) . '/DibiMsSqlReflector.php';
@@ -211,7 +211,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
return "'" . str_replace("'", "''", $value) . "'";
case dibi::IDENTIFIER:
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
// @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
case dibi::BOOL:
@@ -363,5 +363,4 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
return is_resource($this->resultSet) ? $this->resultSet : NULL;
}
}

View File

@@ -3,7 +3,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
*
* Copyright (c) 2005, 2010 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005, 2010 David Grudl (https://davidgrudl.com)
*
* @package dibi\drivers
*/
@@ -34,10 +34,10 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
*/
public function getTables()
{
$res = $this->driver->query("
$res = $this->driver->query('
SELECT TABLE_NAME, TABLE_TYPE
FROM INFORMATION_SCHEMA.TABLES
");
');
$tables = array();
while ($row = $res->fetch(FALSE)) {
$tables[] = array(
@@ -52,12 +52,12 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
/**
* Returns count of rows in a table
* @param string
* @return integer
* @return int
*/
public function getTableCount($table, $fallback=true)
public function getTableCount($table, $fallback = TRUE)
{
if (empty($table)) {
return false;
return FALSE;
}
$result = $this->driver->query("
SELECT MAX(rowcnt)
@@ -71,7 +71,7 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
$row = $this->driver->query("SELECT COUNT(*) FROM {$this->driver->escape($table, dibi::IDENTIFIER)}")->fetch(FALSE);
$count = intval($row[0]);
} else {
$count = false;
$count = FALSE;
}
} else {
$count = intval($row[0]);
@@ -96,16 +96,16 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
");
$columns = array();
while ($row = $res->fetch(TRUE)) {
$size = false;
$size = FALSE;
$type = strtoupper($row['DATA_TYPE']);
$size_cols = array(
'DATETIME'=>'DATETIME_PRECISION',
'DECIMAL'=>'NUMERIC_PRECISION',
'CHAR'=>'CHARACTER_MAXIMUM_LENGTH',
'NCHAR'=>'CHARACTER_OCTET_LENGTH',
'NVARCHAR'=>'CHARACTER_OCTET_LENGTH',
'VARCHAR'=>'CHARACTER_OCTET_LENGTH'
'DATETIME' => 'DATETIME_PRECISION',
'DECIMAL' => 'NUMERIC_PRECISION',
'CHAR' => 'CHARACTER_MAXIMUM_LENGTH',
'NCHAR' => 'CHARACTER_OCTET_LENGTH',
'NVARCHAR' => 'CHARACTER_OCTET_LENGTH',
'VARCHAR' => 'CHARACTER_OCTET_LENGTH',
);
if (isset($size_cols[$type])) {
@@ -122,7 +122,7 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
'unsigned' => NULL,
'nullable' => $row['IS_NULLABLE'] === 'YES',
'default' => $row['COLUMN_DEFAULT'],
'autoincrement' => false,
'autoincrement' => FALSE,
'vendor' => $row,
);
}
@@ -161,8 +161,8 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
if (!isset($indexes[$index_name])) {
$indexes[$index_name] = array();
$indexes[$index_name]['name'] = $index_name;
$indexes[$index_name]['unique'] = (bool)$row['is_unique'];
$indexes[$index_name]['primary'] = (bool)$row['is_primary_key'];
$indexes[$index_name]['unique'] = (bool) $row['is_unique'];
$indexes[$index_name]['primary'] = (bool) $row['is_primary_key'];
$indexes[$index_name]['columns'] = array();
}
$indexes[$index_name]['columns'][] = $row['column_name'];
@@ -203,8 +203,8 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
$keys[$key_name]['local'] = array($row['column_name']); // local columns
$keys[$key_name]['table'] = $row['reference_table_name']; // referenced table
$keys[$key_name]['foreign'] = array($row['reference_column_name']); // referenced columns
$keys[$key_name]['onDelete'] = false;
$keys[$key_name]['onUpdate'] = false;
$keys[$key_name]['onDelete'] = FALSE;
$keys[$key_name]['onUpdate'] = FALSE;
} else {
$keys[$key_name]['local'][] = $row['column_name']; // local columns
$keys[$key_name]['foreign'][] = $row['reference_column_name']; // referenced columns

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -406,8 +406,8 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
* @throws DibiException
*/
public function seek($row)

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -36,7 +36,7 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE()
");*/
$res = $this->driver->query("SHOW FULL TABLES");
$res = $this->driver->query('SHOW FULL TABLES');
$tables = array();
while ($row = $res->fetch(FALSE)) {
$tables[] = array(
@@ -138,9 +138,9 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
$keyName = $row['CONSTRAINT_NAME'];
$foreignKeys[$keyName]['name'] = $keyName;
$foreignKeys[$keyName]['local'] = explode(",", $row['COLUMNS']);
$foreignKeys[$keyName]['local'] = explode(',', $row['COLUMNS']);
$foreignKeys[$keyName]['table'] = $row['REFERENCED_TABLE_NAME'];
$foreignKeys[$keyName]['foreign'] = explode(",", $row['REFERENCED_COLUMNS']);
$foreignKeys[$keyName]['foreign'] = explode(',', $row['REFERENCED_COLUMNS']);
$foreignKeys[$keyName]['onDelete'] = $row['DELETE_RULE'];
$foreignKeys[$keyName]['onUpdate'] = $row['UPDATE_RULE'];
}

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -389,8 +389,8 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
* @throws DibiException
*/
public function seek($row)

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -339,7 +339,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
}
$count = odbc_num_fields($set);
$cols = array();
for ($i = 1; $i <= $count; $i++) $cols[] = odbc_result($set, $i);
for ($i = 1; $i <= $count; $i++) {
$cols[] = odbc_result($set, $i);
}
return $cols;
}
}
@@ -347,8 +349,8 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
*/
public function seek($row)
{
@@ -378,10 +380,10 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
$columns = array();
for ($i = 1; $i <= $count; $i++) {
$columns[] = array(
'name' => odbc_field_name($this->resultSet, $i),
'table' => NULL,
'fullname' => odbc_field_name($this->resultSet, $i),
'nativetype'=> odbc_field_type($this->resultSet, $i),
'name' => odbc_field_name($this->resultSet, $i),
'table' => NULL,
'fullname' => odbc_field_name($this->resultSet, $i),
'nativetype' => odbc_field_type($this->resultSet, $i),
);
}
return $columns;

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -331,8 +331,8 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
*/
public function seek($row)
{

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -64,12 +64,13 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
if ($config['resource'] instanceof PDO) {
$this->connection = $config['resource'];
} else try {
} else {
try {
$this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
} catch (PDOException $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode());
}
}
if (!$this->connection) {
throw new DibiDriverException('Connecting error.');
@@ -401,7 +402,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @return bool TRUE on success, FALSE if unable to seek to specified record
*/
public function seek($row)
{

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -154,7 +154,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
{
if ($sequence === NULL) {
// PostgreSQL 8.1 is needed
$res = $this->query("SELECT LASTVAL()");
$res = $this->query('SELECT LASTVAL()');
} else {
$res = $this->query("SELECT CURRVAL('$sequence')");
}
@@ -300,8 +300,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
*/
public function escapeLike($value, $pos)
{
$bs = pg_escape_string($this->connection, '\\'); // standard_conforming_strings = on/off
$value = pg_escape_string($this->connection, $value);
$value = strtr($value, array( '%' => '\\\\%', '_' => '\\\\_'));
$value = strtr($value, array('%' => $bs . '%', '_' => $bs . '_', '\\' => '\\\\'));
return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
}
@@ -375,7 +376,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @return bool TRUE on success, FALSE if unable to seek to specified record
*/
public function seek($row)
{
@@ -453,14 +454,14 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
table_schema = ANY (current_schemas(false))";
if ($version >= 9.3) {
$query .= "
$query .= '
UNION ALL
SELECT
matviewname, 1
FROM
pg_matviews
WHERE
schemaname = ANY (current_schemas(false))";
schemaname = ANY (current_schemas(false))';
}
$res = $this->query($query);

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -66,11 +66,12 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
if (isset($config['resource']) && $config['resource'] instanceof SQLite3) {
$this->connection = $config['resource'];
} else try {
$this->connection = new SQLite3($config['database']);
} catch (Exception $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode());
} else {
try {
$this->connection = new SQLite3($config['database']);
} catch (Exception $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode());
}
}
$this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
@@ -82,7 +83,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
// enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
$version = SQLite3::version();
if ($version['versionNumber'] >= '3006019') {
$this->query("PRAGMA foreign_keys = ON");
$this->query('PRAGMA foreign_keys = ON');
}
}
@@ -336,8 +337,8 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
* @throws DibiNotSupportedException
*/
public function seek($row)
@@ -368,7 +369,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
static $types = array(SQLITE3_INTEGER => 'int', SQLITE3_FLOAT => 'float', SQLITE3_TEXT => 'text', SQLITE3_BLOB => 'blob', SQLITE3_NULL => 'null');
for ($i = 0; $i < $count; $i++) {
$columns[] = array(
'name' => $this->resultSet->columnName($i),
'name' => $this->resultSet->columnName($i),
'table' => NULL,
'fullname' => $this->resultSet->columnName($i),
'nativetype' => $types[$this->resultSet->columnType($i)],

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -332,8 +332,8 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @param int the 0-based cursor pos to seek to
* @return bool TRUE on success, FALSE if unable to seek to specified record
* @throws DibiException
*/
public function seek($row)
@@ -367,7 +367,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
$name = str_replace(array('[', ']'), '', sqlite_field_name($this->resultSet, $i));
$pair = explode('.', $name);
$columns[] = array(
'name' => isset($pair[1]) ? $pair[1] : $pair[0],
'name' => isset($pair[1]) ? $pair[1] : $pair[0],
'table' => isset($pair[1]) ? $pair[0] : NULL,
'fullname' => $name,
'nativetype' => NULL,

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -29,18 +29,18 @@ class dibi
AFFECTED_ROWS = 'a';
/** @deprecated */
const FIELD_TEXT = dibi::TEXT,
FIELD_BINARY = dibi::BINARY,
FIELD_BOOL = dibi::BOOL,
FIELD_INTEGER = dibi::INTEGER,
FIELD_FLOAT = dibi::FLOAT,
FIELD_DATE = dibi::DATE,
FIELD_DATETIME = dibi::DATETIME,
FIELD_TIME = dibi::TIME;
const FIELD_TEXT = self::TEXT,
FIELD_BINARY = self::BINARY,
FIELD_BOOL = self::BOOL,
FIELD_INTEGER = self::INTEGER,
FIELD_FLOAT = self::FLOAT,
FIELD_DATE = self::DATE,
FIELD_DATETIME = self::DATETIME,
FIELD_TIME = self::TIME;
/** version */
const VERSION = '2.2.2',
REVISION = 'released on 2014-06-30';
const VERSION = '2.2.5',
REVISION = 'released on 2015-10-26';
/** sorting order */
const ASC = 'ASC',
@@ -76,7 +76,7 @@ class dibi
*/
final public function __construct()
{
throw new LogicException("Cannot instantiate static class " . get_class($this));
throw new LogicException('Cannot instantiate static class ' . get_class($this));
}
@@ -296,7 +296,7 @@ class dibi
* @return int
* @throws DibiException
*/
public static function getInsertId($sequence=NULL)
public static function getInsertId($sequence = NULL)
{
return self::getConnection()->getInsertId($sequence);
}
@@ -308,7 +308,7 @@ class dibi
* @return int
* @throws DibiException
*/
public static function insertId($sequence=NULL)
public static function insertId($sequence = NULL)
{
return self::getConnection()->getInsertId($sequence);
}
@@ -479,7 +479,7 @@ class dibi
$sql = preg_replace("#(?<=[\\s,(])($keywords1)(?=[\\s,)])#i", "\n\$1", $sql);
// reduce spaces
$sql = preg_replace('#[ \t]{2,}#', " ", $sql);
$sql = preg_replace('#[ \t]{2,}#', ' ', $sql);
$sql = wordwrap($sql, 100);
$sql = preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql);

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -12,16 +12,12 @@
* @author David Grudl
* @package dibi
*
* @property-read bool $connected
* @property-read mixed $config
* @property-read IDibiDriver $driver
* @property-read int $affectedRows
* @property-read int $insertId
* @property-read DibiDatabaseInfo $databaseInfo
*/
class DibiConnection extends DibiObject
{
/** @var array of function(DibiEvent $event); Occurs after query is executed */
/** @var array of function (DibiEvent $event); Occurs after query is executed */
public $onEvent;
/** @var array Current connection configuration */

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -11,11 +11,6 @@
*
* @author David Grudl
* @package dibi
*
* @property-read DibiConnection $connection
* @property-read DibiResult $result
* @property-read DibiResultIterator $iterator
* @property-read int $totalCount
*/
class DibiDataSource extends DibiObject implements IDataSource
{

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -117,8 +117,8 @@ class DibiDriverException extends DibiException
* @author David Grudl
* @package dibi
*/
class DibiPcreException extends Exception {
class DibiPcreException extends Exception
{
public function __construct($message = '%msg.')
{
static $messages = array(

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -58,7 +58,7 @@ class DibiFileLogger extends DibiObject
);
} else {
fwrite($handle,
"OK: " . $event->sql
'OK: ' . $event->sql
. ($event->count ? ";\n-- rows: " . $event->count : '')
. "\n-- takes: " . sprintf('%0.3f ms', $event->time * 1000)
. "\n-- source: " . implode(':', $event->source)

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -64,7 +64,7 @@ class DibiFirePhpLogger extends DibiObject
sprintf('%0.3f', $event->time * 1000),
strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql,
$event->result instanceof Exception ? 'ERROR' : (string) $event->count,
$event->connection->getConfig('driver') . '/' . $event->connection->getConfig('name')
$event->connection->getConfig('driver') . '/' . $event->connection->getConfig('name'),
);
header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -12,9 +12,6 @@
* @author David Grudl
* @package dibi
*
* @property-read string $command
* @property-read DibiConnection $connection
* @property-read DibiResultIterator $iterator
* @method DibiFluent select($field)
* @method DibiFluent distinct()
* @method DibiFluent from($table)
@@ -24,6 +21,8 @@
* @method DibiFluent orderBy($field)
* @method DibiFluent limit(int $limit)
* @method DibiFluent offset(int $offset)
* @method DibiFluent leftJoin($table)
* @method DibiFluent on($cond)
*/
class DibiFluent extends DibiObject implements IDataSource
{
@@ -189,6 +188,7 @@ class DibiFluent extends DibiObject implements IDataSource
foreach ($args as $arg) {
if ($arg instanceof self) {
$this->cursor[] = '%SQL';
$arg = "($arg)";
}
$this->cursor[] = $arg;
@@ -317,7 +317,7 @@ class DibiFluent extends DibiObject implements IDataSource
*/
public function fetch()
{
if ($this->command === 'SELECT') {
if ($this->command === 'SELECT' && !$this->clauses['LIMIT'] && !$this->clauses['OFFSET']) {
return $this->query($this->_export(NULL, array('%lmt', 1)))->fetch();
} else {
return $this->query($this->_export())->fetch();
@@ -331,7 +331,7 @@ class DibiFluent extends DibiObject implements IDataSource
*/
public function fetchSingle()
{
if ($this->command === 'SELECT') {
if ($this->command === 'SELECT' && !$this->clauses['LIMIT'] && !$this->clauses['OFFSET']) {
return $this->query($this->_export(NULL, array('%lmt', 1)))->fetchSingle();
} else {
return $this->query($this->_export())->fetchSingle();
@@ -403,7 +403,7 @@ class DibiFluent extends DibiObject implements IDataSource
public function count()
{
return (int) $this->query(array(
'SELECT COUNT(*) FROM (%ex', $this->_export(), ') AS [data]'
'SELECT COUNT(*) FROM (%ex', $this->_export(), ') [data]',
))->fetchSingle();
}

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,14 +2,14 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
/**
* DibiObject is the ultimate ancestor of all instantiable classes.
*
* DibiObject is copy of Nette\Object from Nette Framework (http://nette.org).
* DibiObject is copy of Nette\Object from Nette Framework (https://nette.org).
*
* It defines some handful methods and enhances object core of PHP:
* - access to undeclared members throws exceptions
@@ -39,7 +39,7 @@
* Adding method to class (i.e. to all instances) works similar to JavaScript
* prototype property. The syntax for adding a new method is:
* <code>
* MyClass::extensionMethod('newMethod', function(MyClass $obj, $arg, ...) { ... });
* MyClass::extensionMethod('newMethod', function (MyClass $obj, $arg, ...) { ... });
* $obj = new MyClass;
* $obj->newMethod($x);
* </code>
@@ -209,8 +209,8 @@ abstract class DibiObject
}
// property getter support
$name[0] = $name[0] & "\xDF"; // case-sensitive checking, capitalize first character
$m = 'get' . $name;
$uname = ucfirst($name);
$m = 'get' . $uname;
if (self::hasAccessor($class, $m)) {
// ampersands:
// - uses & __get() because declaration should be forward compatible (e.g. with Nette\Web\Html)
@@ -219,13 +219,12 @@ abstract class DibiObject
return $val;
}
$m = 'is' . $name;
$m = 'is' . $uname;
if (self::hasAccessor($class, $m)) {
$val = $this->$m();
return $val;
}
$name = func_get_arg(0);
throw new LogicException("Cannot read an undeclared property $class::\$$name.");
}
@@ -246,20 +245,18 @@ abstract class DibiObject
}
// property setter support
$name[0] = $name[0] & "\xDF"; // case-sensitive checking, capitalize first character
if (self::hasAccessor($class, 'get' . $name) || self::hasAccessor($class, 'is' . $name)) {
$uname = ucfirst($name);
if (self::hasAccessor($class, 'get' . $uname) || self::hasAccessor($class, 'is' . $uname)) {
$m = 'set' . $name;
if (self::hasAccessor($class, $m)) {
$this->$m($value);
return;
} else {
$name = func_get_arg(0);
throw new LogicException("Cannot assign to a read-only property $class::\$$name.");
}
}
$name = func_get_arg(0);
throw new LogicException("Cannot assign to an undeclared property $class::\$$name.");
}
@@ -271,8 +268,7 @@ abstract class DibiObject
*/
public function __isset($name)
{
$name[0] = $name[0] & "\xDF";
return $name !== '' && self::hasAccessor(get_class($this), 'get' . $name);
return $name !== '' && self::hasAccessor(get_class($this), 'get' . ucfirst($name));
}

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -25,12 +25,7 @@
* @author David Grudl
* @package dibi
*
* @property-read mixed $resource
* @property-read IDibiResultDriver $driver
* @property-read int $rowCount
* @property-read DibiResultIterator $iterator
* @property string $rowClass
* @property-read DibiResultInfo $info
*/
class DibiResult extends DibiObject implements IDataSource
{
@@ -109,7 +104,7 @@ class DibiResult extends DibiObject implements IDataSource
/**
* Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to
* @return boolean TRUE on success, FALSE if unable to seek to specified record
* @return bool TRUE on success, FALSE if unable to seek to specified record
* @throws DibiException
*/
final public function seek($row)
@@ -188,7 +183,7 @@ class DibiResult extends DibiObject implements IDataSource
/**
* Fetches the row at current position, process optional type conversion.
* and moves the internal cursor to the next position
* @return DibiRow|FALSE array on success, FALSE if no next record
* @return DibiRow|FALSE array on success, FALSE if no next record
*/
final public function fetch()
{
@@ -209,7 +204,7 @@ class DibiResult extends DibiObject implements IDataSource
/**
* Like fetch(), but returns only first field.
* @return mixed value on success, FALSE if no next record
* @return mixed value on success, FALSE if no next record
*/
final public function fetchSingle()
{
@@ -303,16 +298,16 @@ class DibiResult extends DibiObject implements IDataSource
$x = & $x[];
} elseif ($as === '=') { // "value" node
$x = $row->{$assoc[$i+1]};
$x = $row->{$assoc[$i + 1]};
continue 2;
} elseif ($as === '->') { // "object" node
if ($x === NULL) {
$x = clone $row;
$x = & $x->{$assoc[$i+1]};
$x = & $x->{$assoc[$i + 1]};
$x = NULL; // prepare child node
} else {
$x = & $x->{$assoc[$i+1]};
$x = & $x->{$assoc[$i + 1]};
}
} elseif ($as !== '|') { // associative-array node
@@ -369,22 +364,21 @@ class DibiResult extends DibiObject implements IDataSource
} elseif ($as === '=') { // "record" node
if ($x === NULL) {
$x = $row->toArray();
$x = & $x[ $assoc[$i+1] ];
$x = & $x[ $assoc[$i + 1] ];
$x = NULL; // prepare child node
} else {
$x = & $x[ $assoc[$i+1] ];
$x = & $x[ $assoc[$i + 1] ];
}
} elseif ($as === '@') { // "object" node
if ($x === NULL) {
$x = clone $row;
$x = & $x->{$assoc[$i+1]};
$x = & $x->{$assoc[$i + 1]};
$x = NULL; // prepare child node
} else {
$x = & $x->{$assoc[$i+1]};
$x = & $x->{$assoc[$i + 1]};
}
} else { // associative-array node
$x = & $x[$row->$as];
}
@@ -424,7 +418,7 @@ class DibiResult extends DibiObject implements IDataSource
if ($value === NULL) {
if ($key !== NULL) {
throw new InvalidArgumentException("Either none or both columns must be specified.");
throw new InvalidArgumentException('Either none or both columns must be specified.');
}
// autodetect
@@ -478,7 +472,8 @@ class DibiResult extends DibiObject implements IDataSource
foreach ($this->getResultDriver()->getResultColumns() as $col) {
$this->types[$col['name']] = $cache->{$col['nativetype']};
}
} catch (DibiNotSupportedException $e) {}
} catch (DibiNotSupportedException $e) {
}
}
@@ -497,10 +492,22 @@ class DibiResult extends DibiObject implements IDataSource
if ($value === FALSE || $type === dibi::TEXT) {
} elseif ($type === dibi::INTEGER) {
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
$row[$key] = is_float($tmp = $value * 1)
? (is_string($value) ? $value : (int) $value)
: $tmp;
} elseif ($type === dibi::FLOAT) {
$row[$key] = ltrim((string) ($tmp = (float) $value), '0') === ltrim(rtrim(rtrim($value, '0'), '.'), '0') ? $tmp : $value;
$value = ltrim($value, '0');
$p = strpos($value, '.');
if ($p !== FALSE) {
$value = rtrim(rtrim($value, '0'), '.');
}
if ($value === '' || $value[0] === '.') {
$value = '0' . $value;
}
$row[$key] = $value === str_replace(',', '.', (string) ($float = (float) $value))
? $float
: $value;
} elseif ($type === dibi::BOOL) {
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';
@@ -619,7 +626,7 @@ class DibiResult extends DibiObject implements IDataSource
foreach ($row as $col => $val) {
$spaces = $maxLen - mb_strlen($col) + 2;
echo "$col" . str_repeat(" ", $spaces) . "$val\n";
echo "$col" . str_repeat(' ', $spaces) . "$val\n";
}
echo "\n";

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
@@ -160,7 +160,7 @@ final class DibiTranslator extends DibiObject
if ($comment) {
$sql[] = "*/";
$sql[] = '*/';
}
$sql = implode(' ', $sql);
@@ -187,7 +187,7 @@ final class DibiTranslator extends DibiObject
public function formatValue($value, $modifier)
{
if ($this->comment) {
return "...";
return '...';
}
if (!$this->driver) {
@@ -489,7 +489,7 @@ final class DibiTranslator extends DibiObject
if ($cursor >= count($this->args)) {
$this->hasError = TRUE;
return "**Extra placeholder**";
return '**Extra placeholder**';
}
$cursor++;
@@ -512,7 +512,7 @@ final class DibiTranslator extends DibiObject
// open comment
$this->ifLevelStart = $this->ifLevel;
$this->comment = TRUE;
return "/*";
return '/*';
}
return '';
@@ -520,11 +520,11 @@ final class DibiTranslator extends DibiObject
if ($this->ifLevelStart === $this->ifLevel) {
$this->ifLevelStart = 0;
$this->comment = FALSE;
return "*/";
return '*/';
} elseif (!$this->comment) {
$this->ifLevelStart = $this->ifLevel;
$this->comment = TRUE;
return "/*";
return '/*';
}
} elseif ($mod === 'end') {
@@ -533,7 +533,7 @@ final class DibiTranslator extends DibiObject
// close comment
$this->ifLevelStart = 0;
$this->comment = FALSE;
return "*/";
return '*/';
}
return '';
@@ -572,10 +572,10 @@ final class DibiTranslator extends DibiObject
return $this->identifiers->{$matches[2]};
} elseif ($matches[3]) { // SQL strings: '...'
return $this->driver->escape( str_replace("''", "'", $matches[4]), dibi::TEXT);
return $this->driver->escape(str_replace("''", "'", $matches[4]), dibi::TEXT);
} elseif ($matches[5]) { // SQL strings: "..."
return $this->driver->escape( str_replace('""', '"', $matches[6]), dibi::TEXT);
return $this->driver->escape(str_replace('""', '"', $matches[6]), dibi::TEXT);
} elseif ($matches[7]) { // string quote
$this->hasError = TRUE;
@@ -588,7 +588,7 @@ final class DibiTranslator extends DibiObject
return $matches[9] == '' ? $this->formatValue($m, FALSE) : $m . $matches[9]; // value or identifier
}
die('this should be never executed');
throw new Exception('this should be never executed');
}

View File

@@ -2,7 +2,7 @@
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (http://davidgrudl.com)
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/

View File

@@ -11,11 +11,10 @@ require __DIR__ . '/../dibi/dibi.php';
echo '<p>Connecting to Sqlite: ';
try {
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -26,11 +25,10 @@ echo "</p>\n";
echo '<p>Connecting to Sqlite: ';
try {
$connection = new DibiConnection(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -42,7 +40,6 @@ echo '<p>Connecting to MySQL: ';
try {
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=cp1250');
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -53,18 +50,17 @@ echo "</p>\n";
echo '<p>Connecting to MySQLi: ';
try {
dibi::connect(array(
'driver' => 'mysqli',
'host' => 'localhost',
'driver' => 'mysqli',
'host' => 'localhost',
'username' => 'root',
'password' => 'xxx',
'database' => 'dibi',
'options' => array(
MYSQLI_OPT_CONNECT_TIMEOUT => 30
'options' => array(
MYSQLI_OPT_CONNECT_TIMEOUT => 30,
),
'flags' => MYSQLI_CLIENT_COMPRESS,
'flags' => MYSQLI_CLIENT_COMPRESS,
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -75,13 +71,12 @@ echo "</p>\n";
echo '<p>Connecting to ODBC: ';
try {
dibi::connect(array(
'driver' => 'odbc',
'driver' => 'odbc',
'username' => 'root',
'password' => '***',
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.__DIR__.'/data/sample.mdb',
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.__DIR__.'/data/sample.mdb',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -92,12 +87,11 @@ echo "</p>\n";
echo '<p>Connecting to PostgreSql: ';
try {
dibi::connect(array(
'driver' => 'postgre',
'string' => 'host=localhost port=5432 dbname=mary',
'driver' => 'postgre',
'string' => 'host=localhost port=5432 dbname=mary',
'persistent' => TRUE,
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -108,11 +102,10 @@ echo "</p>\n";
echo '<p>Connecting to Sqlite via PDO: ';
try {
dibi::connect(array(
'driver' => 'pdo',
'dsn' => 'sqlite2::memory:',
'driver' => 'pdo',
'dsn' => 'sqlite2::memory:',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -123,13 +116,12 @@ echo "</p>\n";
echo '<p>Connecting to MS SQL: ';
try {
dibi::connect(array(
'driver' => 'mssql',
'host' => 'localhost',
'driver' => 'mssql',
'host' => 'localhost',
'username' => 'root',
'password' => 'xxx',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -140,14 +132,13 @@ echo "</p>\n";
echo '<p>Connecting to MS SQL 2005: ';
try {
dibi::connect(array(
'driver' => 'mssql2005',
'host' => '(local)',
'driver' => 'mssql2005',
'host' => '(local)',
'username' => 'Administrator',
'password' => 'xxx',
'database' => 'main',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
@@ -158,13 +149,12 @@ echo "</p>\n";
echo '<p>Connecting to Oracle: ';
try {
dibi::connect(array(
'driver' => 'oracle',
'driver' => 'oracle',
'username' => 'root',
'password' => 'xxx',
'database' => 'db',
));
echo 'OK';
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
@@ -37,7 +37,7 @@ foreach ($table->getColumns() as $column) {
echo "</ul>\n";
echo "Indexes";
echo 'Indexes';
echo "<ul>\n";
foreach ($table->getIndexes() as $index) {
echo "<li>{$index->name} " . ($index->primary ? 'primary ' : '') . ($index->unique ? 'unique' : '') . ' (';

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));

View File

@@ -12,7 +12,7 @@ Tracy\Debugger::enable();
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
@@ -32,13 +32,13 @@ dibi::test('
// if & else & (optional) end
dibi::test("
dibi::test('
SELECT *
FROM people
WHERE id > 0
%if", ($foo > 0), "AND foo=?", $foo, "
%else %if", ($bar > 0), "AND bar=?", $bar, "
");
%if', ($foo > 0), 'AND foo=?', $foo, '
%else %if', ($bar > 0), 'AND bar=?', $bar, '
');
// -> SELECT * FROM people WHERE id > 0 AND bar=2

View File

@@ -10,7 +10,7 @@ date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
@@ -45,26 +45,26 @@ $array = array(
'brand' => NULL,
'created' => new DateTime,
);
dibi::test("INSERT INTO products", $array, $array, $array);
dibi::test('INSERT INTO products', $array, $array, $array);
// -> INSERT INTO products ([title], [price], [brand], [created]) VALUES ('Super Product', ...) , (...) , (...)
// dibi detects UPDATE command
dibi::test("
UPDATE colors SET", array(
dibi::test('
UPDATE colors SET', array(
'color' => 'blue',
'order' => 12,
), "
WHERE id=?", 123);
), '
WHERE id=?', 123);
// -> UPDATE colors SET [color]='blue', [order]=12 WHERE id=123
// modifier applied to array
$array = array(1, 2, 3);
dibi::test("
dibi::test('
SELECT *
FROM people
WHERE id IN (?)", $array
WHERE id IN (?)', $array
);
// -> SELECT * FROM people WHERE id IN ( 1, 2, 3 )
@@ -74,11 +74,11 @@ $order = array(
'field1' => 'asc',
'field2' => 'desc',
);
dibi::test("
dibi::test('
SELECT *
FROM people
ORDER BY %by", $order, "
");
ORDER BY %by', $order, '
');
// -> SELECT * FROM people ORDER BY [field1] ASC, [field2] DESC

View File

@@ -14,7 +14,7 @@ date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
@@ -27,7 +27,7 @@ $res->setType('customer_id', Dibi::INTEGER)
->setFormat(dibi::DATETIME, 'Y-m-d H:i:s');
Tracy\Dumper::dump( $res->fetch() );
Tracy\Dumper::dump($res->fetch());
// outputs:
// DibiRow(3) {
// customer_id => 1
@@ -38,7 +38,7 @@ Tracy\Dumper::dump( $res->fetch() );
// using auto-detection (works well with MySQL or other strictly typed databases)
$res = dibi::query('SELECT * FROM [customers]');
Tracy\Dumper::dump( $res->fetch() );
Tracy\Dumper::dump($res->fetch());
// outputs:
// DibiRow(3) {
// customer_id => 1

View File

@@ -2,11 +2,7 @@
<h1>Tracy & SQL Exceptions | dibi</h1>
<p>Dibi can display and log exceptions via Tracy, part of Nette Framework.</p>
<ul>
<li>Tracy Debugger: http://tracy.nette.org
</ul>
<p>Dibi can display and log exceptions via <a href="https://tracy.nette.org">Tracy</a>.</p>
<?php
@@ -15,29 +11,22 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
}
// enable Tracy
Tracy\Debugger::enable();
dibi::connect(array(
'driver' => 'sqlite3',
$connection = dibi::connect(array(
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => array(
'run' => TRUE,
)
),
));
// throws error because SQL is bad
dibi::query('SELECT * FROM customers WHERE customer_id < ?', 38);
dibi::connect(array(
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => array(
'run' => TRUE,
)
));
// add panel to debug bar
$panel = new Dibi\Bridges\Tracy\Panel;
$panel->register($connection);
// throws error because SQL is bad

View File

@@ -1,32 +0,0 @@
<!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 & Variables | dibi</h1>
<p>Dibi can dump variables via Tracy, part of Nette Framework.</p>
<ul>
<li>Tracy Debugger: http://tracy.nette.org
</ul>
<?php
if (@!include __DIR__ . '/../vendor/autoload.php') {
die('Install dependencies using `composer install --dev`');
}
Tracy\Debugger::enable();
dibi::connect(array(
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => array(
'run' => TRUE,
)
));
Tracy\Debugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]' );

38
examples/tracy.php Normal file
View File

@@ -0,0 +1,38 @@
<!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
if (@!include __DIR__ . '/../vendor/autoload.php') {
die('Install dependencies using `composer install --dev`');
}
// enable Tracy
Tracy\Debugger::enable();
$connection = dibi::connect(array(
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => array(
'run' => TRUE,
),
));
// add panel to debug bar
$panel = new Dibi\Bridges\Tracy\Panel;
$panel->register($connection);
// query will be logged
dibi::query('SELECT 123');
// result set will be dumped
Tracy\Debugger::barDump(dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]');

View File

@@ -11,7 +11,7 @@ date_default_timezone_set('Europe/Prague');
// CHANGE TO REAL PARAMETERS!
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'formatDate' => "'Y-m-d'",
'formatDateTime' => "'Y-m-d H-i-s'",
@@ -19,10 +19,10 @@ dibi::connect(array(
// generate and dump SQL
dibi::test("
INSERT INTO [mytable]", array(
'id' => 123,
'date' => new DateTime('12.3.2007'),
dibi::test('
INSERT INTO [mytable]', array(
'id' => 123,
'date' => new DateTime('12.3.2007'),
'stamp' => new DateTime('23.1.2007 10:23'),
)
);

View File

@@ -12,14 +12,13 @@ Tracy\Debugger::enable();
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
// using the "prototype" to add custom method to class DibiResult
DibiResult::extensionMethod('fetchShuffle', function(DibiResult $obj)
{
DibiResult::extensionMethod('fetchShuffle', function (DibiResult $obj) {
$all = $obj->fetchAll();
shuffle($all);
return $all;

View File

@@ -10,15 +10,15 @@ date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
$id = 10;
$record = array(
'title' => 'Super product',
'price' => 318,
'title' => 'Super product',
'price' => 318,
'active' => TRUE,
);

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));

View File

@@ -10,7 +10,7 @@ date_default_timezone_set('Europe/Prague');
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
// enable query logging to this file
'profiler' => array(
@@ -26,13 +26,12 @@ try {
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < ?', 5);
$res = dibi::query('SELECT FROM [customers] WHERE [customer_id] < ?', 38);
} catch (DibiException $e) {
echo '<p>', get_class($e), ': ', $e->getMessage(), '</p>';
}
// outputs a log file
echo "<h2>File data/log.sql:</h2>";
echo '<h2>File data/log.sql:</h2>';
echo '<pre>', file_get_contents('data/log.sql'), '</pre>';

View File

@@ -10,16 +10,16 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
'profiler' => array(
'run' => TRUE,
)
),
));
// execute some queries...
for ($i=0; $i<20; $i++) {
for ($i = 0; $i < 20; $i++) {
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < ?', $i);
}

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));
@@ -16,7 +16,7 @@ dibi::connect(array(
// create new substitution :blog: ==> wp_
dibi::getSubstitutes()->blog = 'wp_';
dibi::test("SELECT * FROM [:blog:items]");
dibi::test('SELECT * FROM [:blog:items]');
// -> SELECT * FROM [wp_items]

View File

@@ -8,7 +8,7 @@ require __DIR__ . '/../dibi/dibi.php';
dibi::connect(array(
'driver' => 'sqlite3',
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
));

View File

@@ -16,7 +16,7 @@ remains intact.
New BSD License
---------------
Copyright (c) 2004, 2014 David Grudl (http://davidgrudl.com)
Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,

View File

@@ -1,13 +1,12 @@
[Dibi](http://dibiphp.com) - smart database layer for PHP [![Buy me a coffee](http://files.nette.org/images/coffee1s.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XXL5ZJHAYQUN)
[Dibi](http://dibiphp.com) - smart database layer for PHP [![Buy me a coffee](https://files.nette.org/images/coffee1s.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9XXL5ZJHAYQUN)
=========================================================
[![Downloads this Month](https://img.shields.io/packagist/dm/dibi/dibi.svg)](https://packagist.org/packages/dibi/dibi)
[![Build Status](https://travis-ci.org/dg/dibi.svg?branch=master)](https://travis-ci.org/dg/dibi)
Database access functions in PHP are not standardised. This library
hides the differences between them, and above all, it gives you a very handy interface.
The best way to install Dibi is to use a [Composer](http://getcomposer.org/download):
The best way to install Dibi is to use a [Composer](https://getcomposer.org/download):
php composer.phar require dibi/dibi

4
tests/.gitignore vendored
View File

@@ -1,4 +0,0 @@
/*/output
/coverage.dat
/test.log
/tmp

View File

@@ -1,40 +0,0 @@
<?php
/**
* Test: Cloning of DibiFluent
*
* @author David Grudl
*/
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
dibi::connect($config['sqlite3']);
$fluent = new DibiFluent(dibi::getConnection());
$fluent->select('*')->from('table')->where('x=1');
$dolly = clone $fluent;
$dolly->where('y=1');
$dolly->clause('FOO');
Assert::same( 'SELECT * FROM [table] WHERE x=1', (string) $fluent );
Assert::same( 'SELECT * FROM [table] WHERE x=1 AND y=1 FOO', (string) $dolly );
$fluent = dibi::select('id')->from('table')->where('id = %i',1);
$dolly = clone $fluent;
$dolly->where('cd = %i',5);
Assert::same( 'SELECT [id] FROM [table] WHERE id = 1', (string) $fluent );
Assert::same( 'SELECT [id] FROM [table] WHERE id = 1 AND cd = 5', (string) $dolly );
$fluent = dibi::select("*")->from("table");
$dolly = clone $fluent;
$dolly->removeClause("select")->select("count(*)");
Assert::same( 'SELECT * FROM [table]', (string) $fluent );
Assert::same( 'SELECT count(*) FROM [table]', (string) $dolly );

View File

@@ -0,0 +1,70 @@
<?php
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
class TestClass extends DibiObject
{
public function getBar()
{
return 123;
}
public function isFoo()
{
return 456;
}
}
// calling
Assert::exception(function () {
$obj = new TestClass;
$obj->undeclared();
}, 'LogicException', 'Call to undefined method TestClass::undeclared().');
Assert::exception(function () {
TestClass::undeclared();
}, 'LogicException', 'Call to undefined static method TestClass::undeclared().');
// writing
Assert::exception(function () {
$obj = new TestClass;
$obj->undeclared = 'value';
}, 'LogicException', 'Cannot assign to an undeclared property TestClass::$undeclared.');
// property getter
$obj = new TestClass;
Assert::true(isset($obj->bar));
Assert::same(123, $obj->bar);
Assert::false(isset($obj->foo));
Assert::same(456, $obj->foo);
// reading
Assert::exception(function () {
$obj = new TestClass;
$val = $obj->undeclared;
}, 'LogicException', 'Cannot read an undeclared property TestClass::$undeclared.');
// unset/isset
Assert::exception(function () {
$obj = new TestClass;
unset($obj->undeclared);
}, 'LogicException', 'Cannot unset the property TestClass::$undeclared.');
Assert::false(isset($obj->undeclared));
// extension method
TestClass::extensionMethod('join', $func = function (TestClass $that, $separator) {
return $that->foo . $separator . $that->bar;
});
$obj = new TestClass;
Assert::same('456*123', $obj->join('*'));

View File

@@ -1,23 +0,0 @@
<?php
/**
* Test: DateTimeInterface of DibiTranslator
*
* @author Patrik Votoček
* @phpversion 5.5
*/
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$connection = new DibiConnection(array(
'driver' => 'sqlite3',
'database' => ':memory:',
));
$translator = new DibiTranslator($connection);
$datetime = new DateTime('1978-01-23 00:00:00');
Assert::equal($datetime->format('U'), $translator->formatValue(new DateTime($datetime->format('c')), NULL));
Assert::equal($datetime->format('U'), $translator->formatValue(new DateTimeImmutable($datetime->format('c')), NULL));

View File

@@ -1,18 +0,0 @@
<?php
// The Nette Tester command-line runner can be
// invoked through the command: ../../vendor/bin/tester .
if (@!include __DIR__ . '/../../vendor/autoload.php') {
echo 'Install Nette Tester using `composer update --dev`';
exit(1);
}
// configure environment
Tester\Environment::setup();
date_default_timezone_set('Europe/Prague');
// load connections
$config = require __DIR__ . '/config.php';

View File

@@ -1,77 +0,0 @@
<?php
return array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'username' => 'root',
'password' => 'xxx',
'charset' => 'utf8',
),
'mysqli' => array(
'driver' => 'mysqli',
'host' => 'localhost',
'username' => 'dibi',
'password' => 'dibi',
'charset' => 'utf8',
),
'sqlite' => array(
'driver' => 'sqlite',
'database' => dirname(__FILE__) . '/data/sample.sdb',
),
'sqlite3' => array(
'driver' => 'sqlite3',
'database' => dirname(__FILE__) . '/data/sample.sdb3',
),
'odbc' => array(
'driver' => 'odbc',
'username' => 'dibi',
'password' => 'dibi',
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq=' . dirname(__FILE__) . '/data/sample.mdb',
),
'postgresql' => array(
'driver' => 'postgre',
'host' => 'localhost',
'port' => '5432',
'username' => 'dibi',
'password' => 'dibi',
'persistent' => '1',
),
'sqlite-pdo' => array(
'driver' => 'pdo',
'dsn' => 'sqlite2::' . dirname(__FILE__) . '/data/sample.sdb',
),
'mysql-pdo' => array(
'driver' => 'pdo',
'dsn' => 'mysql:host=localhost',
'username' => 'dibi',
'password' => 'dibi',
),
'mssql' => array(
'driver' => 'mssql',
'host' => 'localhost',
'username' => 'dibi',
'password' => 'dibi',
),
'mssql2005' => array(
'driver' => 'mssql2005',
'host' => '(local)',
'username' => 'dibi',
'password' => 'dibi',
),
'oracle' => array(
'driver' => 'oracle',
'username' => 'dibi',
'password' => 'dibi',
),
);

Binary file not shown.

View File

@@ -1,92 +0,0 @@
-- MySQL: 5.0.45
SET FOREIGN_KEY_CHECKS=0;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- --------------------------------------------------------
DROP TABLE IF EXISTS `customers`;
CREATE TABLE IF NOT EXISTS `customers` (
`customer_id` int(11) NOT NULL auto_increment,
`name` varchar(100) default NULL,
PRIMARY KEY (`customer_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
INSERT INTO `customers` (`customer_id`, `name`) VALUES
(1, 'Dave Lister'),
(2, 'Arnold Rimmer'),
(3, 'The Cat'),
(4, 'Holly'),
(5, 'Kryten'),
(6, 'Kristine Kochanski');
-- --------------------------------------------------------
DROP TABLE IF EXISTS `enumtest`;
CREATE TABLE IF NOT EXISTS `enumtest` (
`id` int(11) NOT NULL auto_increment,
`test` enum('a','b','c') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
DROP TABLE IF EXISTS `orders`;
CREATE TABLE IF NOT EXISTS `orders` (
`order_id` int(11) NOT NULL,
`customer_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`amount` float NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `orders` (`order_id`, `customer_id`, `product_id`, `amount`) VALUES
(1, 2, 1, 7),
(2, 2, 3, 2),
(3, 1, 2, 3),
(4, 6, 3, 5);
-- --------------------------------------------------------
DROP TABLE IF EXISTS `products`;
CREATE TABLE IF NOT EXISTS `products` (
`product_id` int(11) NOT NULL auto_increment,
`title` varchar(100) default NULL,
PRIMARY KEY (`product_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
INSERT INTO `products` (`product_id`, `title`) VALUES
(1, 'Chair'),
(2, 'Table'),
(3, 'Computer');
-- --------------------------------------------------------
DROP TABLE IF EXISTS `settest`;
CREATE TABLE IF NOT EXISTS `settest` (
`id` int(11) NOT NULL auto_increment,
`test` set('a','b','c') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
DROP TABLE IF EXISTS `where`;
CREATE TABLE IF NOT EXISTS `where` (
`select` int(11) NOT NULL,
`dot.dot` int(11) NOT NULL,
`is` int(11) NOT NULL,
`quot'n' space` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `where` (`select`, `dot.dot`, `is`, `quot'n' space`) VALUES
(1, 2, 3, 4);
SET FOREIGN_KEY_CHECKS=1;
SET SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";

Binary file not shown.

Binary file not shown.

View File

@@ -1,2 +0,0 @@
[PHP]
;extension_dir = "./ext"

View File

@@ -1,3 +0,0 @@
[PHP]
extension_dir = "./ext"
extension=php_sqlite3.dll

View File

@@ -1 +0,0 @@
Dibi 2.2.2 (released on 2014-06-30)