diff --git a/dibi/dibi.php b/dibi/dibi.php index b5489a93..e5c9d1bd 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -26,6 +26,7 @@ if (version_compare(PHP_VERSION, '5.1.0', '<')) { throw new Exception('dibi needs PHP 5.1.0 or newer.'); } +@set_magic_quotes_runtime(FALSE); // intentionally @ @@ -525,7 +526,7 @@ class dibi public static function select($args) { $args = func_get_args(); - return self::getConnection()->command()->__call('select', $args); + return call_user_func_array(array(self::getConnection(), 'select'), $args); } @@ -648,7 +649,8 @@ class dibi public static function setSubstFallback($callback) { if (!is_callable($callback)) { - throw new InvalidArgumentException("Invalid callback."); + $able = is_callable($callback, TRUE, $textual); + throw new InvalidArgumentException("Handler '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.')); } self::$substFallBack = $callback; diff --git a/dibi/libs/DibiTranslator.php b/dibi/libs/DibiTranslator.php index 2e9207b6..a9fecfd9 100644 --- a/dibi/libs/DibiTranslator.php +++ b/dibi/libs/DibiTranslator.php @@ -260,7 +260,7 @@ final class DibiTranslator extends DibiObject $pair = explode('%', $k, 2); // split into identifier & modifier $vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : FALSE); } - return '(' . implode(', ', $vx) . ')'; + return '(' . ($vx ? implode(', ', $vx) : 'NULL') . ')'; case 'v': // (key, key, ...) VALUES (val, val, ...) @@ -291,7 +291,7 @@ final class DibiTranslator extends DibiObject foreach ($value as $v) { $vx[] = $this->formatValue($v, $modifier); } - return implode(', ', $vx); + return $vx ? implode(', ', $vx) : 'NULL'; } } diff --git a/dibi/libs/interfaces.php b/dibi/libs/interfaces.php index 74e7ece4..9e47e0e5 100644 --- a/dibi/libs/interfaces.php +++ b/dibi/libs/interfaces.php @@ -122,8 +122,6 @@ interface IDibiDriver */ function connect(array &$config); - - /** * Disconnects from a database. * @return void @@ -131,8 +129,6 @@ interface IDibiDriver */ function disconnect(); - - /** * Internal: Executes the SQL query. * @param string SQL statement. @@ -141,24 +137,18 @@ interface IDibiDriver */ function query($sql); - - /** * Gets the number of affected rows by the last INSERT, UPDATE or DELETE query. * @return int|FALSE number of rows or FALSE on error */ function getAffectedRows(); - - /** * Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query. * @return int|FALSE int on success or FALSE on failure */ function getInsertId($sequence); - - /** * Begins a transaction (if supported). * @param string optinal savepoint name @@ -167,8 +157,6 @@ interface IDibiDriver */ function begin($savepoint = NULL); - - /** * Commits statements in a transaction. * @param string optinal savepoint name @@ -177,8 +165,6 @@ interface IDibiDriver */ function commit($savepoint = NULL); - - /** * Rollback changes in a transaction. * @param string optinal savepoint name @@ -187,8 +173,6 @@ interface IDibiDriver */ function rollback($savepoint = NULL); - - /** * Returns the connection resource. * @return mixed @@ -210,8 +194,6 @@ interface IDibiDriver */ function escape($value, $type); - - /** * Decodes data from result set. * @param string value @@ -221,8 +203,6 @@ interface IDibiDriver */ function unescape($value, $type); - - /** * Injects LIMIT/OFFSET to the SQL query. * @param string &$sql The SQL query that will be modified. @@ -244,8 +224,6 @@ interface IDibiDriver */ function getRowCount(); - - /** * Moves cursor position without fetching row. * @param int the 0-based cursor pos to seek to @@ -254,8 +232,6 @@ interface IDibiDriver */ function seek($row); - - /** * Fetches the row at current position and moves the internal cursor to the next position. * @param bool TRUE for associative array, FALSE for numeric @@ -264,8 +240,6 @@ interface IDibiDriver */ function fetch($type); - - /** * Frees the resources allocated for this result set. * @param resource result set resource @@ -273,8 +247,6 @@ interface IDibiDriver */ function free(); - - /** * Returns metadata for all columns in a result set. * @return array @@ -282,8 +254,6 @@ interface IDibiDriver */ function getColumnsMeta(); - - /** * Returns the result set resource. * @return mixed @@ -302,8 +272,6 @@ interface IDibiDriver */ function getTables(); - - /** * Returns metadata for all columns in a table. * @param string @@ -311,8 +279,6 @@ interface IDibiDriver */ function getColumns($table); - - /** * Returns metadata for all indexes in a table. * @param string @@ -320,8 +286,6 @@ interface IDibiDriver */ function getIndexes($table); - - /** * Returns metadata for all foreign keys in a table. * @param string diff --git a/examples/datetime.demo.php b/examples/datetime.demo.php index 33e29155..d50c61ee 100644 --- a/examples/datetime.demo.php +++ b/examples/datetime.demo.php @@ -4,8 +4,6 @@ require_once 'Nette/Debug.php'; require_once '../dibi/dibi.php'; - -// required since PHP 5.1.0 date_default_timezone_set('Europe/Prague'); diff --git a/examples/fluent.test.php b/examples/fluent.test.php index 9aa4b7c4..7dea3f99 100644 --- a/examples/fluent.test.php +++ b/examples/fluent.test.php @@ -4,6 +4,8 @@ require_once 'Nette/Debug.php'; require_once '../dibi/dibi.php'; +date_default_timezone_set('Europe/Prague'); + dibi::connect(array( 'driver' => 'sqlite', diff --git a/examples/logger.php b/examples/logger.php index 74f1feca..088c7872 100644 --- a/examples/logger.php +++ b/examples/logger.php @@ -4,6 +4,8 @@ require_once 'Nette/Debug.php'; require_once '../dibi/dibi.php'; +date_default_timezone_set('Europe/Prague'); + dibi::connect(array( 'driver' => 'sqlite', diff --git a/examples/metatypes.php b/examples/metatypes.php index a8b9f81a..89f48a8a 100644 --- a/examples/metatypes.php +++ b/examples/metatypes.php @@ -5,6 +5,8 @@ require_once 'Nette/Debug.php'; require_once '../dibi/dibi.php'; +date_default_timezone_set('Europe/Prague'); + dibi::connect(array( 'driver' => 'sqlite', diff --git a/examples/sql-builder.php b/examples/sql-builder.php index 7b286e2d..7a997171 100644 --- a/examples/sql-builder.php +++ b/examples/sql-builder.php @@ -8,7 +8,6 @@ pre.dibi { padding-bottom: 10px; } require_once 'Nette/Debug.php'; require_once '../dibi/dibi.php'; -// required since PHP 5.1.0 date_default_timezone_set('Europe/Prague');