1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +02:00

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
This commit is contained in:
David Grudl
2015-06-19 03:11:36 +02:00
parent df37a500fa
commit ce459f440a
44 changed files with 183 additions and 191 deletions

View File

@@ -124,7 +124,8 @@ class DibiNettePanel extends DibiObject implements IBarPanel
$event->connection->onEvent = NULL; $event->connection->onEvent = NULL;
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN' : 'EXPLAIN'); $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); $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; list($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime) = $backup;
} }

View File

@@ -7,8 +7,8 @@
namespace Dibi\Bridges\Nette; namespace Dibi\Bridges\Nette;
use dibi, use dibi;
Nette; use Nette;
/** /**

View File

@@ -7,13 +7,13 @@
namespace Dibi\Bridges\Tracy; namespace Dibi\Bridges\Tracy;
use dibi, use dibi;
Tracy; use Tracy;
/** /**
* Dibi panel for Tracy. * Dibi panel for Tracy.
* * @package dibi\nette
* @author David Grudl * @author David Grudl
*/ */
class Panel extends \DibiObject implements Tracy\IBarPanel class Panel extends \DibiObject implements Tracy\IBarPanel
@@ -108,7 +108,8 @@ class Panel extends \DibiObject implements Tracy\IBarPanel
$event->connection->onEvent = NULL; $event->connection->onEvent = NULL;
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN' : 'EXPLAIN'); $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); $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; list($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime) = $backup;
} }

View File

@@ -88,7 +88,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
throw new DibiDriverException(ibase_errmsg(), ibase_errcode()); throw new DibiDriverException(ibase_errmsg(), ibase_errcode());
} }
} }
} }
@@ -349,7 +348,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
*/ */
public function getRowCount() 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.');
} }
@@ -380,12 +379,12 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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 * @throws DibiException
*/ */
public function seek($row) 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 END AS TRIGGER_ENABLED
FROM RDB\$TRIGGERS FROM RDB\$TRIGGERS
WHERE RDB\$SYSTEM_FLAG = 0" WHERE RDB\$SYSTEM_FLAG = 0"
. ($table === NULL ? ";" : " AND RDB\$RELATION_NAME = UPPER('$table');") . ($table === NULL ? ';' : " AND RDB\$RELATION_NAME = UPPER('$table');")
); );
$triggers = array(); $triggers = array();
while ($row = $res->fetch(TRUE)) { while ($row = $res->fetch(TRUE)) {
@@ -683,7 +682,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
$q = "SELECT TRIM(RDB\$TRIGGER_NAME) $q = "SELECT TRIM(RDB\$TRIGGER_NAME)
FROM RDB\$TRIGGERS FROM RDB\$TRIGGERS
WHERE RDB\$SYSTEM_FLAG = 0"; 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); $res = $this->query($q);
$triggers = array(); $triggers = array();

View File

@@ -328,7 +328,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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) public function seek($row)
{ {

View File

@@ -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)}"); $keyUsagesRes = $this->driver->query("SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = {$this->driver->escape($table, dibi::TEXT)}");
$keyUsages = array(); $keyUsages = array();
while( $row = $keyUsagesRes->fetch(TRUE) ) { while ($row = $keyUsagesRes->fetch(TRUE)) {
$keyUsages[$row['CONSTRAINT_NAME']][(int) $row['ORDINAL_POSITION'] - 1] = $row['COLUMN_NAME']; $keyUsages[$row['CONSTRAINT_NAME']][(int) $row['ORDINAL_POSITION'] - 1] = $row['COLUMN_NAME'];
} }

View File

@@ -363,5 +363,4 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
return is_resource($this->resultSet) ? $this->resultSet : NULL; return is_resource($this->resultSet) ? $this->resultSet : NULL;
} }
} }

View File

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

View File

@@ -407,7 +407,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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 * @throws DibiException
*/ */
public function seek($row) public function seek($row)

View File

@@ -36,7 +36,7 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
FROM INFORMATION_SCHEMA.TABLES FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE() WHERE TABLE_SCHEMA = DATABASE()
");*/ ");*/
$res = $this->driver->query("SHOW FULL TABLES"); $res = $this->driver->query('SHOW FULL TABLES');
$tables = array(); $tables = array();
while ($row = $res->fetch(FALSE)) { while ($row = $res->fetch(FALSE)) {
$tables[] = array( $tables[] = array(
@@ -138,9 +138,9 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
$keyName = $row['CONSTRAINT_NAME']; $keyName = $row['CONSTRAINT_NAME'];
$foreignKeys[$keyName]['name'] = $keyName; $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]['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]['onDelete'] = $row['DELETE_RULE'];
$foreignKeys[$keyName]['onUpdate'] = $row['UPDATE_RULE']; $foreignKeys[$keyName]['onUpdate'] = $row['UPDATE_RULE'];
} }

View File

@@ -390,7 +390,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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 * @throws DibiException
*/ */
public function seek($row) public function seek($row)

View File

@@ -339,7 +339,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
} }
$count = odbc_num_fields($set); $count = odbc_num_fields($set);
$cols = array(); $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; return $cols;
} }
} }
@@ -348,7 +350,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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) public function seek($row)
{ {
@@ -381,7 +383,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
'name' => odbc_field_name($this->resultSet, $i), 'name' => odbc_field_name($this->resultSet, $i),
'table' => NULL, 'table' => NULL,
'fullname' => odbc_field_name($this->resultSet, $i), 'fullname' => odbc_field_name($this->resultSet, $i),
'nativetype'=> odbc_field_type($this->resultSet, $i), 'nativetype' => odbc_field_type($this->resultSet, $i),
); );
} }
return $columns; return $columns;

View File

@@ -332,7 +332,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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) public function seek($row)
{ {

View File

@@ -64,12 +64,13 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
if ($config['resource'] instanceof PDO) { if ($config['resource'] instanceof PDO) {
$this->connection = $config['resource']; $this->connection = $config['resource'];
} else try { } else {
try {
$this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']); $this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
} catch (PDOException $e) { } catch (PDOException $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode()); throw new DibiDriverException($e->getMessage(), $e->getCode());
} }
}
if (!$this->connection) { if (!$this->connection) {
throw new DibiDriverException('Connecting error.'); throw new DibiDriverException('Connecting error.');
@@ -401,7 +402,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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) public function seek($row)
{ {

View File

@@ -154,7 +154,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
{ {
if ($sequence === NULL) { if ($sequence === NULL) {
// PostgreSQL 8.1 is needed // PostgreSQL 8.1 is needed
$res = $this->query("SELECT LASTVAL()"); $res = $this->query('SELECT LASTVAL()');
} else { } else {
$res = $this->query("SELECT CURRVAL('$sequence')"); $res = $this->query("SELECT CURRVAL('$sequence')");
} }
@@ -376,7 +376,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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) public function seek($row)
{ {
@@ -454,14 +454,14 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
table_schema = ANY (current_schemas(false))"; table_schema = ANY (current_schemas(false))";
if ($version >= 9.3) { if ($version >= 9.3) {
$query .= " $query .= '
UNION ALL UNION ALL
SELECT SELECT
matviewname, 1 matviewname, 1
FROM FROM
pg_matviews pg_matviews
WHERE WHERE
schemaname = ANY (current_schemas(false))"; schemaname = ANY (current_schemas(false))';
} }
$res = $this->query($query); $res = $this->query($query);

View File

@@ -66,12 +66,13 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
if (isset($config['resource']) && $config['resource'] instanceof SQLite3) { if (isset($config['resource']) && $config['resource'] instanceof SQLite3) {
$this->connection = $config['resource']; $this->connection = $config['resource'];
} else try { } else {
try {
$this->connection = new SQLite3($config['database']); $this->connection = new SQLite3($config['database']);
} catch (Exception $e) { } catch (Exception $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode()); throw new DibiDriverException($e->getMessage(), $e->getCode());
} }
}
$this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset']; $this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
$this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset']; $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
@@ -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) // enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
$version = SQLite3::version(); $version = SQLite3::version();
if ($version['versionNumber'] >= '3006019') { if ($version['versionNumber'] >= '3006019') {
$this->query("PRAGMA foreign_keys = ON"); $this->query('PRAGMA foreign_keys = ON');
} }
} }
@@ -337,7 +338,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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 DibiNotSupportedException * @throws DibiNotSupportedException
*/ */
public function seek($row) public function seek($row)

View File

@@ -333,7 +333,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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 * @throws DibiException
*/ */
public function seek($row) public function seek($row)

View File

@@ -29,14 +29,14 @@ class dibi
AFFECTED_ROWS = 'a'; AFFECTED_ROWS = 'a';
/** @deprecated */ /** @deprecated */
const FIELD_TEXT = dibi::TEXT, const FIELD_TEXT = self::TEXT,
FIELD_BINARY = dibi::BINARY, FIELD_BINARY = self::BINARY,
FIELD_BOOL = dibi::BOOL, FIELD_BOOL = self::BOOL,
FIELD_INTEGER = dibi::INTEGER, FIELD_INTEGER = self::INTEGER,
FIELD_FLOAT = dibi::FLOAT, FIELD_FLOAT = self::FLOAT,
FIELD_DATE = dibi::DATE, FIELD_DATE = self::DATE,
FIELD_DATETIME = dibi::DATETIME, FIELD_DATETIME = self::DATETIME,
FIELD_TIME = dibi::TIME; FIELD_TIME = self::TIME;
/** version */ /** version */
const VERSION = '2.2.3', const VERSION = '2.2.3',
@@ -76,7 +76,7 @@ class dibi
*/ */
final public function __construct() 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 * @return int
* @throws DibiException * @throws DibiException
*/ */
public static function getInsertId($sequence=NULL) public static function getInsertId($sequence = NULL)
{ {
return self::getConnection()->getInsertId($sequence); return self::getConnection()->getInsertId($sequence);
} }
@@ -308,7 +308,7 @@ class dibi
* @return int * @return int
* @throws DibiException * @throws DibiException
*/ */
public static function insertId($sequence=NULL) public static function insertId($sequence = NULL)
{ {
return self::getConnection()->getInsertId($sequence); return self::getConnection()->getInsertId($sequence);
} }
@@ -479,7 +479,7 @@ class dibi
$sql = preg_replace("#(?<=[\\s,(])($keywords1)(?=[\\s,)])#i", "\n\$1", $sql); $sql = preg_replace("#(?<=[\\s,(])($keywords1)(?=[\\s,)])#i", "\n\$1", $sql);
// reduce spaces // reduce spaces
$sql = preg_replace('#[ \t]{2,}#', " ", $sql); $sql = preg_replace('#[ \t]{2,}#', ' ', $sql);
$sql = wordwrap($sql, 100); $sql = wordwrap($sql, 100);
$sql = preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql); $sql = preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql);

View File

@@ -21,7 +21,7 @@
*/ */
class DibiConnection extends DibiObject 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; public $onEvent;
/** @var array Current connection configuration */ /** @var array Current connection configuration */

View File

@@ -117,8 +117,8 @@ class DibiDriverException extends DibiException
* @author David Grudl * @author David Grudl
* @package dibi * @package dibi
*/ */
class DibiPcreException extends Exception { class DibiPcreException extends Exception
{
public function __construct($message = '%msg.') public function __construct($message = '%msg.')
{ {
static $messages = array( static $messages = array(

View File

@@ -58,7 +58,7 @@ class DibiFileLogger extends DibiObject
); );
} else { } else {
fwrite($handle, fwrite($handle,
"OK: " . $event->sql 'OK: ' . $event->sql
. ($event->count ? ";\n-- rows: " . $event->count : '') . ($event->count ? ";\n-- rows: " . $event->count : '')
. "\n-- takes: " . sprintf('%0.3f ms', $event->time * 1000) . "\n-- takes: " . sprintf('%0.3f ms', $event->time * 1000)
. "\n-- source: " . implode(':', $event->source) . "\n-- source: " . implode(':', $event->source)

View File

@@ -64,7 +64,7 @@ class DibiFirePhpLogger extends DibiObject
sprintf('%0.3f', $event->time * 1000), sprintf('%0.3f', $event->time * 1000),
strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql,
$event->result instanceof Exception ? 'ERROR' : (string) $event->count, $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'); header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');

View File

@@ -405,7 +405,7 @@ class DibiFluent extends DibiObject implements IDataSource
public function count() public function count()
{ {
return (int) $this->query(array( return (int) $this->query(array(
'SELECT COUNT(*) FROM (%ex', $this->_export(), ') AS [data]' 'SELECT COUNT(*) FROM (%ex', $this->_export(), ') AS [data]',
))->fetchSingle(); ))->fetchSingle();
} }

View File

@@ -39,7 +39,7 @@
* Adding method to class (i.e. to all instances) works similar to JavaScript * Adding method to class (i.e. to all instances) works similar to JavaScript
* prototype property. The syntax for adding a new method is: * prototype property. The syntax for adding a new method is:
* <code> * <code>
* MyClass::extensionMethod('newMethod', function(MyClass $obj, $arg, ...) { ... }); * MyClass::extensionMethod('newMethod', function (MyClass $obj, $arg, ...) { ... });
* $obj = new MyClass; * $obj = new MyClass;
* $obj->newMethod($x); * $obj->newMethod($x);
* </code> * </code>

View File

@@ -109,7 +109,7 @@ class DibiResult extends DibiObject implements IDataSource
/** /**
* Moves cursor position without fetching row. * Moves cursor position without fetching row.
* @param int the 0-based cursor pos to seek to * @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 * @throws DibiException
*/ */
final public function seek($row) final public function seek($row)
@@ -303,16 +303,16 @@ class DibiResult extends DibiObject implements IDataSource
$x = & $x[]; $x = & $x[];
} elseif ($as === '=') { // "value" node } elseif ($as === '=') { // "value" node
$x = $row->{$assoc[$i+1]}; $x = $row->{$assoc[$i + 1]};
continue 2; continue 2;
} elseif ($as === '->') { // "object" node } elseif ($as === '->') { // "object" node
if ($x === NULL) { if ($x === NULL) {
$x = clone $row; $x = clone $row;
$x = & $x->{$assoc[$i+1]}; $x = & $x->{$assoc[$i + 1]};
$x = NULL; // prepare child node $x = NULL; // prepare child node
} else { } else {
$x = & $x->{$assoc[$i+1]}; $x = & $x->{$assoc[$i + 1]};
} }
} elseif ($as !== '|') { // associative-array node } elseif ($as !== '|') { // associative-array node
@@ -369,22 +369,21 @@ class DibiResult extends DibiObject implements IDataSource
} elseif ($as === '=') { // "record" node } elseif ($as === '=') { // "record" node
if ($x === NULL) { if ($x === NULL) {
$x = $row->toArray(); $x = $row->toArray();
$x = & $x[ $assoc[$i+1] ]; $x = & $x[ $assoc[$i + 1] ];
$x = NULL; // prepare child node $x = NULL; // prepare child node
} else { } else {
$x = & $x[ $assoc[$i+1] ]; $x = & $x[ $assoc[$i + 1] ];
} }
} elseif ($as === '@') { // "object" node } elseif ($as === '@') { // "object" node
if ($x === NULL) { if ($x === NULL) {
$x = clone $row; $x = clone $row;
$x = & $x->{$assoc[$i+1]}; $x = & $x->{$assoc[$i + 1]};
$x = NULL; // prepare child node $x = NULL; // prepare child node
} else { } else {
$x = & $x->{$assoc[$i+1]}; $x = & $x->{$assoc[$i + 1]};
} }
} else { // associative-array node } else { // associative-array node
$x = & $x[$row->$as]; $x = & $x[$row->$as];
} }
@@ -424,7 +423,7 @@ class DibiResult extends DibiObject implements IDataSource
if ($value === NULL) { if ($value === NULL) {
if ($key !== 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 // autodetect
@@ -478,7 +477,8 @@ class DibiResult extends DibiObject implements IDataSource
foreach ($this->getResultDriver()->getResultColumns() as $col) { foreach ($this->getResultDriver()->getResultColumns() as $col) {
$this->types[$col['name']] = $cache->{$col['nativetype']}; $this->types[$col['name']] = $cache->{$col['nativetype']};
} }
} catch (DibiNotSupportedException $e) {} } catch (DibiNotSupportedException $e) {
}
} }
@@ -619,7 +619,7 @@ class DibiResult extends DibiObject implements IDataSource
foreach ($row as $col => $val) { foreach ($row as $col => $val) {
$spaces = $maxLen - mb_strlen($col) + 2; $spaces = $maxLen - mb_strlen($col) + 2;
echo "$col" . str_repeat(" ", $spaces) . "$val\n"; echo "$col" . str_repeat(' ', $spaces) . "$val\n";
} }
echo "\n"; echo "\n";

View File

@@ -160,7 +160,7 @@ final class DibiTranslator extends DibiObject
if ($comment) { if ($comment) {
$sql[] = "*/"; $sql[] = '*/';
} }
$sql = implode(' ', $sql); $sql = implode(' ', $sql);
@@ -187,7 +187,7 @@ final class DibiTranslator extends DibiObject
public function formatValue($value, $modifier) public function formatValue($value, $modifier)
{ {
if ($this->comment) { if ($this->comment) {
return "..."; return '...';
} }
if (!$this->driver) { if (!$this->driver) {
@@ -489,7 +489,7 @@ final class DibiTranslator extends DibiObject
if ($cursor >= count($this->args)) { if ($cursor >= count($this->args)) {
$this->hasError = TRUE; $this->hasError = TRUE;
return "**Extra placeholder**"; return '**Extra placeholder**';
} }
$cursor++; $cursor++;
@@ -512,7 +512,7 @@ final class DibiTranslator extends DibiObject
// open comment // open comment
$this->ifLevelStart = $this->ifLevel; $this->ifLevelStart = $this->ifLevel;
$this->comment = TRUE; $this->comment = TRUE;
return "/*"; return '/*';
} }
return ''; return '';
@@ -520,11 +520,11 @@ final class DibiTranslator extends DibiObject
if ($this->ifLevelStart === $this->ifLevel) { if ($this->ifLevelStart === $this->ifLevel) {
$this->ifLevelStart = 0; $this->ifLevelStart = 0;
$this->comment = FALSE; $this->comment = FALSE;
return "*/"; return '*/';
} elseif (!$this->comment) { } elseif (!$this->comment) {
$this->ifLevelStart = $this->ifLevel; $this->ifLevelStart = $this->ifLevel;
$this->comment = TRUE; $this->comment = TRUE;
return "/*"; return '/*';
} }
} elseif ($mod === 'end') { } elseif ($mod === 'end') {
@@ -533,7 +533,7 @@ final class DibiTranslator extends DibiObject
// close comment // close comment
$this->ifLevelStart = 0; $this->ifLevelStart = 0;
$this->comment = FALSE; $this->comment = FALSE;
return "*/"; return '*/';
} }
return ''; return '';
@@ -572,10 +572,10 @@ final class DibiTranslator extends DibiObject
return $this->identifiers->{$matches[2]}; return $this->identifiers->{$matches[2]};
} elseif ($matches[3]) { // SQL strings: '...' } 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: "..." } 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 } elseif ($matches[7]) { // string quote
$this->hasError = TRUE; $this->hasError = TRUE;

View File

@@ -15,7 +15,6 @@ try {
'database' => 'data/sample.s3db', 'database' => 'data/sample.s3db',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -30,7 +29,6 @@ try {
'database' => 'data/sample.s3db', 'database' => 'data/sample.s3db',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -42,7 +40,6 @@ echo '<p>Connecting to MySQL: ';
try { try {
dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=cp1250'); dibi::connect('driver=mysql&host=localhost&username=root&password=xxx&database=test&charset=cp1250');
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -59,12 +56,11 @@ try {
'password' => 'xxx', 'password' => 'xxx',
'database' => 'dibi', 'database' => 'dibi',
'options' => array( 'options' => array(
MYSQLI_OPT_CONNECT_TIMEOUT => 30 MYSQLI_OPT_CONNECT_TIMEOUT => 30,
), ),
'flags' => MYSQLI_CLIENT_COMPRESS, 'flags' => MYSQLI_CLIENT_COMPRESS,
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -81,7 +77,6 @@ try {
'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.__DIR__.'/data/sample.mdb', 'dsn' => 'Driver={Microsoft Access Driver (*.mdb)};Dbq='.__DIR__.'/data/sample.mdb',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -97,7 +92,6 @@ try {
'persistent' => TRUE, 'persistent' => TRUE,
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -112,7 +106,6 @@ try {
'dsn' => 'sqlite2::memory:', 'dsn' => 'sqlite2::memory:',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -129,7 +122,6 @@ try {
'password' => 'xxx', 'password' => 'xxx',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -147,7 +139,6 @@ try {
'database' => 'main', 'database' => 'main',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }
@@ -164,7 +155,6 @@ try {
'database' => 'db', 'database' => 'db',
)); ));
echo 'OK'; echo 'OK';
} catch (DibiException $e) { } catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n"; echo get_class($e), ': ', $e->getMessage(), "\n";
} }

View File

@@ -37,7 +37,7 @@ foreach ($table->getColumns() as $column) {
echo "</ul>\n"; echo "</ul>\n";
echo "Indexes"; echo 'Indexes';
echo "<ul>\n"; echo "<ul>\n";
foreach ($table->getIndexes() as $index) { foreach ($table->getIndexes() as $index) {
echo "<li>{$index->name} " . ($index->primary ? 'primary ' : '') . ($index->unique ? 'unique' : '') . ' ('; echo "<li>{$index->name} " . ($index->primary ? 'primary ' : '') . ($index->unique ? 'unique' : '') . ' (';

View File

@@ -32,13 +32,13 @@ dibi::test('
// if & else & (optional) end // if & else & (optional) end
dibi::test(" dibi::test('
SELECT * SELECT *
FROM people FROM people
WHERE id > 0 WHERE id > 0
%if", ($foo > 0), "AND foo=?", $foo, " %if', ($foo > 0), 'AND foo=?', $foo, '
%else %if", ($bar > 0), "AND bar=?", $bar, " %else %if', ($bar > 0), 'AND bar=?', $bar, '
"); ');
// -> SELECT * FROM people WHERE id > 0 AND bar=2 // -> SELECT * FROM people WHERE id > 0 AND bar=2

View File

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

View File

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

View File

@@ -20,7 +20,7 @@ $connection = dibi::connect(array(
'database' => 'data/sample.s3db', 'database' => 'data/sample.s3db',
'profiler' => array( 'profiler' => array(
'run' => TRUE, 'run' => TRUE,
) ),
)); ));

View File

@@ -22,7 +22,7 @@ $connection = dibi::connect(array(
'database' => 'data/sample.s3db', 'database' => 'data/sample.s3db',
'profiler' => array( 'profiler' => array(
'run' => TRUE, 'run' => TRUE,
) ),
)); ));
@@ -35,4 +35,4 @@ $panel->register($connection);
dibi::query('SELECT 123'); dibi::query('SELECT 123');
// result set will be dumped // result set will be dumped
Tracy\Debugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]' ); Tracy\Debugger::barDump(dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]');

View File

@@ -19,8 +19,8 @@ dibi::connect(array(
// generate and dump SQL // generate and dump SQL
dibi::test(" dibi::test('
INSERT INTO [mytable]", array( INSERT INTO [mytable]', array(
'id' => 123, 'id' => 123,
'date' => new DateTime('12.3.2007'), 'date' => new DateTime('12.3.2007'),
'stamp' => new DateTime('23.1.2007 10:23'), 'stamp' => new DateTime('23.1.2007 10:23'),

View File

@@ -18,8 +18,7 @@ dibi::connect(array(
// using the "prototype" to add custom method to class DibiResult // 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(); $all = $obj->fetchAll();
shuffle($all); shuffle($all);
return $all; return $all;

View File

@@ -26,13 +26,12 @@ try {
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < ?', 5); $res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < ?', 5);
$res = dibi::query('SELECT FROM [customers] WHERE [customer_id] < ?', 38); $res = dibi::query('SELECT FROM [customers] WHERE [customer_id] < ?', 38);
} catch (DibiException $e) { } catch (DibiException $e) {
echo '<p>', get_class($e), ': ', $e->getMessage(), '</p>'; echo '<p>', get_class($e), ': ', $e->getMessage(), '</p>';
} }
// outputs a log file // 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>'; echo '<pre>', file_get_contents('data/log.sql'), '</pre>';

View File

@@ -14,12 +14,12 @@ dibi::connect(array(
'database' => 'data/sample.s3db', 'database' => 'data/sample.s3db',
'profiler' => array( 'profiler' => array(
'run' => TRUE, 'run' => TRUE,
) ),
)); ));
// execute some queries... // 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); $res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < ?', $i);
} }

View File

@@ -16,7 +16,7 @@ dibi::connect(array(
// create new substitution :blog: ==> wp_ // create new substitution :blog: ==> wp_
dibi::getSubstitutes()->blog = 'wp_'; dibi::getSubstitutes()->blog = 'wp_';
dibi::test("SELECT * FROM [:blog:items]"); dibi::test('SELECT * FROM [:blog:items]');
// -> SELECT * FROM [wp_items] // -> SELECT * FROM [wp_items]