mirror of
https://github.com/dg/dibi.git
synced 2025-07-31 19:30:30 +02:00
typos & whitespace
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dibi extension for Nette Framework 2.0. Creates 'connection' service.
|
* Dibi extension for Nette Framework 2.0. Creates 'connection' service.
|
||||||
*
|
*
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dibi extension for Nette Framework 2.1. Creates 'connection' service.
|
* Dibi extension for Nette Framework 2.1. Creates 'connection' service.
|
||||||
*
|
*
|
||||||
|
@@ -10,13 +10,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (interface_exists('Nette\Diagnostics\IBarPanel')) {
|
if (interface_exists('Nette\Diagnostics\IBarPanel')) {
|
||||||
class_alias('Nette\Diagnostics\IBarPanel', 'IBarPanel');
|
class_alias('Nette\Diagnostics\IBarPanel', 'IBarPanel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dibi panel for Nette\Diagnostics.
|
* Dibi panel for Nette\Diagnostics.
|
||||||
*
|
*
|
||||||
@@ -38,7 +36,6 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
private $events = array();
|
private $events = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($explain = TRUE, $filter = NULL)
|
public function __construct($explain = TRUE, $filter = NULL)
|
||||||
{
|
{
|
||||||
$this->filter = $filter ? (int) $filter : DibiEvent::QUERY;
|
$this->filter = $filter ? (int) $filter : DibiEvent::QUERY;
|
||||||
@@ -46,7 +43,6 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function register(DibiConnection $connection)
|
public function register(DibiConnection $connection)
|
||||||
{
|
{
|
||||||
if (is_callable('Nette\Diagnostics\Debugger::enable') && !class_exists('NDebugger')) {
|
if (is_callable('Nette\Diagnostics\Debugger::enable') && !class_exists('NDebugger')) {
|
||||||
@@ -70,7 +66,6 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After event notification.
|
* After event notification.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -84,7 +79,6 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns blue-screen custom tab.
|
* Returns blue-screen custom tab.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -100,7 +94,6 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML code for custom tab. (Nette\Diagnostics\IBarPanel)
|
* Returns HTML code for custom tab. (Nette\Diagnostics\IBarPanel)
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -118,7 +111,6 @@ class DibiNettePanel extends DibiObject implements IBarPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML code for custom panel. (Nette\Diagnostics\IBarPanel)
|
* Returns HTML code for custom panel. (Nette\Diagnostics\IBarPanel)
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@@ -20,7 +20,6 @@ if (version_compare(PHP_VERSION, '5.2.0', '<')) {
|
|||||||
@set_magic_quotes_runtime(FALSE); // intentionally @
|
@set_magic_quotes_runtime(FALSE); // intentionally @
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/libs/interfaces.php';
|
require_once dirname(__FILE__) . '/libs/interfaces.php';
|
||||||
require_once dirname(__FILE__) . '/libs/DibiDateTime.php';
|
require_once dirname(__FILE__) . '/libs/DibiDateTime.php';
|
||||||
require_once dirname(__FILE__) . '/libs/DibiObject.php';
|
require_once dirname(__FILE__) . '/libs/DibiObject.php';
|
||||||
@@ -43,9 +42,6 @@ if (interface_exists('Nette\Diagnostics\IBarPanel') || interface_exists('IBarPan
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for database drivers.
|
* Interface for database drivers.
|
||||||
*
|
*
|
||||||
@@ -112,7 +108,6 @@ class dibi
|
|||||||
public static $defaultDriver = 'mysql';
|
public static $defaultDriver = 'mysql';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static class - cannot be instantiated.
|
* Static class - cannot be instantiated.
|
||||||
*/
|
*/
|
||||||
@@ -122,11 +117,9 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* connections handling ****************d*g**/
|
/********************* connections handling ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new DibiConnection object and connects it to specified database.
|
* Creates a new DibiConnection object and connects it to specified database.
|
||||||
* @param mixed connection parameters
|
* @param mixed connection parameters
|
||||||
@@ -140,7 +133,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from database (doesn't destroy DibiConnection object).
|
* Disconnects from database (doesn't destroy DibiConnection object).
|
||||||
* @return void
|
* @return void
|
||||||
@@ -151,7 +143,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns TRUE when connection was established.
|
* Returns TRUE when connection was established.
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -162,7 +153,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve active connection.
|
* Retrieve active connection.
|
||||||
* @param string connection registy name
|
* @param string connection registy name
|
||||||
@@ -187,7 +177,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets connection.
|
* Sets connection.
|
||||||
* @param DibiConnection
|
* @param DibiConnection
|
||||||
@@ -199,7 +188,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change active connection.
|
* Change active connection.
|
||||||
* @param string connection registy name
|
* @param string connection registy name
|
||||||
@@ -212,11 +200,9 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* monostate for active connection ****************d*g**/
|
/********************* monostate for active connection ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and executes SQL query - Monostate for DibiConnection::query().
|
* Generates and executes SQL query - Monostate for DibiConnection::query().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -230,7 +216,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query - Monostate for DibiConnection::nativeQuery().
|
* Executes the SQL query - Monostate for DibiConnection::nativeQuery().
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -242,7 +227,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and prints SQL query - Monostate for DibiConnection::test().
|
* Generates and prints SQL query - Monostate for DibiConnection::test().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -255,7 +239,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and returns SQL query as DibiDataSource - Monostate for DibiConnection::test().
|
* Generates and returns SQL query as DibiDataSource - Monostate for DibiConnection::test().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -268,7 +251,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch result - Monostate for DibiConnection::query() & fetch().
|
* Executes SQL query and fetch result - Monostate for DibiConnection::query() & fetch().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -282,7 +264,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch results - Monostate for DibiConnection::query() & fetchAll().
|
* Executes SQL query and fetch results - Monostate for DibiConnection::query() & fetchAll().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -296,7 +277,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch first column - Monostate for DibiConnection::query() & fetchSingle().
|
* Executes SQL query and fetch first column - Monostate for DibiConnection::query() & fetchSingle().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -310,7 +290,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch pairs - Monostate for DibiConnection::query() & fetchPairs().
|
* Executes SQL query and fetch pairs - Monostate for DibiConnection::query() & fetchPairs().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -324,7 +303,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows.
|
* Gets the number of affected rows.
|
||||||
* Monostate for DibiConnection::getAffectedRows()
|
* Monostate for DibiConnection::getAffectedRows()
|
||||||
@@ -337,7 +315,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows. Alias for getAffectedRows().
|
* Gets the number of affected rows. Alias for getAffectedRows().
|
||||||
* @return int number of rows
|
* @return int number of rows
|
||||||
@@ -349,7 +326,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* Monostate for DibiConnection::getInsertId()
|
* Monostate for DibiConnection::getInsertId()
|
||||||
@@ -363,7 +339,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
|
* Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
|
||||||
* @param string optional sequence name
|
* @param string optional sequence name
|
||||||
@@ -376,7 +351,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction - Monostate for DibiConnection::begin().
|
* Begins a transaction - Monostate for DibiConnection::begin().
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -389,7 +363,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction - Monostate for DibiConnection::commit($savepoint = NULL).
|
* Commits statements in a transaction - Monostate for DibiConnection::commit($savepoint = NULL).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -402,7 +375,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction - Monostate for DibiConnection::rollback().
|
* Rollback changes in a transaction - Monostate for DibiConnection::rollback().
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -415,7 +387,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a information about the current database - Monostate for DibiConnection::getDatabaseInfo().
|
* Gets a information about the current database - Monostate for DibiConnection::getDatabaseInfo().
|
||||||
* @return DibiDatabaseInfo
|
* @return DibiDatabaseInfo
|
||||||
@@ -426,7 +397,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import SQL dump from file - extreme fast!
|
* Import SQL dump from file - extreme fast!
|
||||||
* @param string filename
|
* @param string filename
|
||||||
@@ -438,24 +408,21 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement for majority of dibi::methods() in future.
|
* Replacement for majority of dibi::methods() in future.
|
||||||
*/
|
*/
|
||||||
public static function __callStatic($name, $args)
|
public static function __callStatic($name, $args)
|
||||||
{
|
{
|
||||||
//if ($name = 'select', 'update', ...') {
|
//if ($name = 'select', 'update', ...') {
|
||||||
// return self::command()->$name($args);
|
// return self::command()->$name($args);
|
||||||
//}
|
//}
|
||||||
return call_user_func_array(array(self::getConnection(), $name), $args);
|
return call_user_func_array(array(self::getConnection(), $name), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* fluent SQL builders ****************d*g**/
|
/********************* fluent SQL builders ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
*/
|
*/
|
||||||
@@ -465,7 +432,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string column name
|
* @param string column name
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
@@ -477,7 +443,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string table
|
* @param string table
|
||||||
* @param array
|
* @param array
|
||||||
@@ -489,7 +454,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string table
|
* @param string table
|
||||||
* @param array
|
* @param array
|
||||||
@@ -501,7 +465,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string table
|
* @param string table
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
@@ -512,11 +475,9 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* data types ****************d*g**/
|
/********************* data types ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiDateTime
|
* @return DibiDateTime
|
||||||
*/
|
*/
|
||||||
@@ -527,7 +488,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -538,11 +498,9 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* substitutions ****************d*g**/
|
/********************* substitutions ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns substitution hashmap - Monostate for DibiConnection::getSubstitutes().
|
* Returns substitution hashmap - Monostate for DibiConnection::getSubstitutes().
|
||||||
* @return DibiHashMap
|
* @return DibiHashMap
|
||||||
@@ -553,7 +511,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public static function addSubst($expr, $subst)
|
public static function addSubst($expr, $subst)
|
||||||
{
|
{
|
||||||
@@ -562,7 +519,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public static function removeSubst($expr)
|
public static function removeSubst($expr)
|
||||||
{
|
{
|
||||||
@@ -578,7 +534,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public static function setSubstFallback($callback)
|
public static function setSubstFallback($callback)
|
||||||
{
|
{
|
||||||
@@ -587,11 +542,9 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* misc tools ****************d*g**/
|
/********************* misc tools ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints out a syntax highlighted version of the SQL command or DibiResult.
|
* Prints out a syntax highlighted version of the SQL command or DibiResult.
|
||||||
* @param string|DibiResult
|
* @param string|DibiResult
|
||||||
@@ -605,7 +558,9 @@ class dibi
|
|||||||
$sql->dump();
|
$sql->dump();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ($sql === NULL) $sql = self::$sql;
|
if ($sql === NULL) {
|
||||||
|
$sql = self::$sql;
|
||||||
|
}
|
||||||
|
|
||||||
static $keywords1 = 'SELECT|(?:ON\s+DUPLICATE\s+KEY)?UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE';
|
static $keywords1 = 'SELECT|(?:ON\s+DUPLICATE\s+KEY)?UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE';
|
||||||
static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|IGNORE|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|RLIKE|REGEXP|TRUE|FALSE';
|
static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|IGNORE|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|RLIKE|REGEXP|TRUE|FALSE';
|
||||||
@@ -643,7 +598,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static function highlightCallback($matches)
|
private static function highlightCallback($matches)
|
||||||
{
|
{
|
||||||
if (!empty($matches[1])) { // comment
|
if (!empty($matches[1])) { // comment
|
||||||
@@ -661,7 +615,6 @@ class dibi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static function cliHighlightCallback($matches)
|
private static function cliHighlightCallback($matches)
|
||||||
{
|
{
|
||||||
if (!empty($matches[1])) { // comment
|
if (!empty($matches[1])) { // comment
|
||||||
|
@@ -56,13 +56,12 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
DibiConnection::alias($config, 'database', 'db');
|
DibiConnection::alias($config, 'database', 'db');
|
||||||
|
|
||||||
@@ -71,11 +70,13 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// default values
|
// default values
|
||||||
if (!isset($config['username'])) $config['username'] = ini_get('ibase.default_password');
|
$config += array(
|
||||||
if (!isset($config['password'])) $config['password'] = ini_get('ibase.default_user');
|
'username' => ini_get('ibase.default_password'),
|
||||||
if (!isset($config['database'])) $config['database'] = ini_get('ibase.default_db');
|
'password' => ini_get('ibase.default_user'),
|
||||||
if (!isset($config['charset'])) $config['charset'] = ini_get('ibase.default_charset');
|
'database' => ini_get('ibase.default_db'),
|
||||||
if (!isset($config['buffers'])) $config['buffers'] = 0;
|
'charset' => ini_get('ibase.default_charset'),
|
||||||
|
'buffers' => 0,
|
||||||
|
);
|
||||||
|
|
||||||
DibiDriverException::tryError();
|
DibiDriverException::tryError();
|
||||||
if (empty($config['persistent'])) {
|
if (empty($config['persistent'])) {
|
||||||
@@ -95,7 +96,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -106,7 +106,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -138,7 +137,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -149,7 +147,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @param string generator name
|
* @param string generator name
|
||||||
@@ -161,7 +158,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -178,7 +174,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -199,7 +194,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -220,7 +214,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is in transaction?
|
* Is in transaction?
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -231,7 +224,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return resource
|
* @return resource
|
||||||
@@ -242,7 +234,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -253,7 +244,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -267,11 +257,9 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ********************/
|
/********************* SQL ********************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -282,29 +270,28 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
return $value;
|
return $value;
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -317,7 +304,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -334,28 +320,22 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
if ($limit >= 0 && $offset > 0) {
|
||||||
|
// see http://scott.yang.id.au/2004/01/limit-in-select-statements-in-firebird/
|
||||||
// see http://scott.yang.id.au/2004/01/limit-in-select-statements-in-firebird/
|
$sql = 'SELECT FIRST ' . (int) $limit . ($offset > 0 ? ' SKIP ' . (int) $offset : '') . ' * FROM (' . $sql . ')';
|
||||||
$sql = 'SELECT FIRST ' . (int) $limit . ($offset > 0 ? ' SKIP ' . (int) $offset : '') . ' * FROM (' . $sql . ')';
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ********************/
|
/********************* result set ********************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -366,7 +346,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -377,7 +356,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -402,7 +380,6 @@ 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
|
||||||
@@ -415,7 +392,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -427,7 +403,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mysqli_result
|
* @return mysqli_result
|
||||||
@@ -439,7 +414,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -461,11 +435,9 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* IDibiReflector ********************/
|
/********************* IDibiReflector ********************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -489,7 +461,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -545,7 +516,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table (the constraints are included).
|
* Returns metadata for all indexes in a table (the constraints are included).
|
||||||
* @param string
|
* @param string
|
||||||
@@ -580,7 +550,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -611,7 +580,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of indices in given table (the constraints are not listed).
|
* Returns list of indices in given table (the constraints are not listed).
|
||||||
* @param string
|
* @param string
|
||||||
@@ -634,7 +602,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of constraints in given table.
|
* Returns list of constraints in given table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -659,7 +626,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all triggers in a table or database.
|
* Returns metadata for all triggers in a table or database.
|
||||||
* (Only if user has permissions on ALTER TABLE, INSERT/UPDATE/DELETE record in table)
|
* (Only if user has permissions on ALTER TABLE, INSERT/UPDATE/DELETE record in table)
|
||||||
@@ -709,7 +675,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of triggers for given table.
|
* Returns list of triggers for given table.
|
||||||
* (Only if user has permissions on ALTER TABLE, INSERT/UPDATE/DELETE record in table)
|
* (Only if user has permissions on ALTER TABLE, INSERT/UPDATE/DELETE record in table)
|
||||||
@@ -732,7 +697,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata from stored procedures and their input and output parameters.
|
* Returns metadata from stored procedures and their input and output parameters.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -786,7 +750,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of stored procedures.
|
* Returns list of stored procedures.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -805,7 +768,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of generators.
|
* Returns list of generators.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -825,7 +787,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of user defined functions (UDF).
|
* Returns list of user defined functions (UDF).
|
||||||
* @return array
|
* @return array
|
||||||
@@ -847,8 +808,6 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database procedure exception.
|
* Database procedure exception.
|
||||||
*
|
*
|
||||||
@@ -875,7 +834,6 @@ class DibiProcedureException extends DibiException
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the exception severity.
|
* Gets the exception severity.
|
||||||
* @return string
|
* @return string
|
||||||
|
@@ -44,7 +44,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
private $affectedRows = FALSE;
|
private $affectedRows = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -56,13 +55,12 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
DibiConnection::alias($config, 'options|UID', 'username');
|
DibiConnection::alias($config, 'options|UID', 'username');
|
||||||
DibiConnection::alias($config, 'options|PWD', 'password');
|
DibiConnection::alias($config, 'options|PWD', 'password');
|
||||||
@@ -74,7 +72,9 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Default values
|
// Default values
|
||||||
if (!isset($config['options']['CharacterSet'])) $config['options']['CharacterSet'] = 'UTF-8';
|
if (!isset($config['options']['CharacterSet'])) {
|
||||||
|
$config['options']['CharacterSet'] = 'UTF-8';
|
||||||
|
}
|
||||||
|
|
||||||
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -97,7 +96,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -120,7 +118,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -131,7 +128,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -147,7 +143,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -160,7 +155,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -173,7 +167,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -186,7 +179,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -197,7 +189,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -208,7 +199,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -222,11 +212,9 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -237,30 +225,29 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
|
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
|
||||||
return '[' . str_replace(']', ']]', $value) . ']';
|
return '[' . str_replace(']', ']]', $value) . ']';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -274,7 +261,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -291,15 +277,11 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
// offset support is missing
|
// offset support is missing
|
||||||
if ($limit >= 0) {
|
if ($limit >= 0) {
|
||||||
@@ -312,11 +294,9 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -327,7 +307,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -338,7 +317,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -350,7 +328,6 @@ 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
|
||||||
@@ -362,7 +339,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -374,7 +350,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -393,7 +368,6 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@@ -23,14 +23,12 @@ class DibiMsSql2005Reflector extends DibiObject implements IDibiReflector
|
|||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver)
|
public function __construct(IDibiDriver $driver)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -49,7 +47,6 @@ class DibiMsSql2005Reflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -102,7 +99,6 @@ class DibiMsSql2005Reflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -128,7 +124,6 @@ class DibiMsSql2005Reflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -38,7 +38,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
private $autoFree = TRUE;
|
private $autoFree = TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -50,13 +49,12 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
@@ -76,7 +74,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -87,7 +84,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -107,7 +103,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -118,7 +113,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -134,7 +128,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -147,7 +140,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -160,7 +152,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -173,7 +164,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -184,7 +174,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -195,7 +184,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -209,11 +197,9 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -224,30 +210,29 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
|
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
|
||||||
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -261,7 +246,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -278,15 +262,11 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
// offset support is missing
|
// offset support is missing
|
||||||
if ($limit >= 0) {
|
if ($limit >= 0) {
|
||||||
@@ -299,11 +279,9 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -314,7 +292,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -325,7 +302,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -337,7 +313,6 @@ class DibiMsSqlDriver 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
|
||||||
@@ -349,7 +324,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -361,7 +335,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -383,7 +356,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@@ -25,14 +25,12 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
|
|||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver)
|
public function __construct(IDibiDriver $driver)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -54,7 +52,6 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns count of rows in a table
|
* Returns count of rows in a table
|
||||||
* @param string
|
* @param string
|
||||||
@@ -87,7 +84,6 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -138,7 +134,6 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -180,7 +175,6 @@ class DibiMsSqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -53,7 +53,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
private $buffered;
|
private $buffered;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -65,13 +64,12 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
@@ -79,17 +77,21 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
} else {
|
} else {
|
||||||
// default values
|
// default values
|
||||||
DibiConnection::alias($config, 'flags', 'options');
|
DibiConnection::alias($config, 'flags', 'options');
|
||||||
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
$config += array(
|
||||||
if (!isset($config['timezone'])) $config['timezone'] = date('P');
|
'charset' => 'utf8',
|
||||||
if (!isset($config['username'])) $config['username'] = ini_get('mysql.default_user');
|
'timezone' => date('P'),
|
||||||
if (!isset($config['password'])) $config['password'] = ini_get('mysql.default_password');
|
'username' => ini_get('mysql.default_user'),
|
||||||
|
'password' => ini_get('mysql.default_password'),
|
||||||
|
);
|
||||||
if (!isset($config['host'])) {
|
if (!isset($config['host'])) {
|
||||||
$host = ini_get('mysql.default_host');
|
$host = ini_get('mysql.default_host');
|
||||||
if ($host) {
|
if ($host) {
|
||||||
$config['host'] = $host;
|
$config['host'] = $host;
|
||||||
$config['port'] = ini_get('mysql.default_port');
|
$config['port'] = ini_get('mysql.default_port');
|
||||||
} else {
|
} else {
|
||||||
if (!isset($config['socket'])) $config['socket'] = ini_get('mysql.default_socket');
|
if (!isset($config['socket'])) {
|
||||||
|
$config['socket'] = ini_get('mysql.default_socket');
|
||||||
|
}
|
||||||
$config['host'] = NULL;
|
$config['host'] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +142,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -151,7 +152,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -175,7 +175,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves information about the most recently executed query.
|
* Retrieves information about the most recently executed query.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -184,7 +183,9 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
{
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
preg_match_all('#(.+?): +(\d+) *#', mysql_info($this->connection), $matches, PREG_SET_ORDER);
|
preg_match_all('#(.+?): +(\d+) *#', mysql_info($this->connection), $matches, PREG_SET_ORDER);
|
||||||
if (preg_last_error()) throw new DibiPcreException;
|
if (preg_last_error()) {
|
||||||
|
throw new DibiPcreException;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($matches as $m) {
|
foreach ($matches as $m) {
|
||||||
$res[$m[1]] = (int) $m[2];
|
$res[$m[1]] = (int) $m[2];
|
||||||
@@ -193,7 +194,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -204,7 +204,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -215,7 +214,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -228,7 +226,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -241,7 +238,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -254,7 +250,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -265,7 +260,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -276,7 +270,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -290,11 +283,9 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -305,38 +296,37 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
throw new DibiException('Lost connection to server.');
|
throw new DibiException('Lost connection to server.');
|
||||||
}
|
}
|
||||||
return "'" . mysql_real_escape_string($value, $this->connection) . "'";
|
return "'" . mysql_real_escape_string($value, $this->connection) . "'";
|
||||||
|
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
throw new DibiException('Lost connection to server.');
|
throw new DibiException('Lost connection to server.');
|
||||||
}
|
}
|
||||||
return "_binary'" . mysql_real_escape_string($value, $this->connection) . "'";
|
return "_binary'" . mysql_real_escape_string($value, $this->connection) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
// @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
|
// @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
|
||||||
return '`' . str_replace('`', '``', $value) . '`';
|
return '`' . str_replace('`', '``', $value) . '`';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -350,7 +340,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -367,29 +356,23 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
if ($limit >= 0 || $offset > 0) {
|
||||||
|
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
|
||||||
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
|
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
||||||
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||||
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -400,7 +383,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -414,7 +396,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -426,7 +407,6 @@ 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
|
||||||
@@ -443,7 +423,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -455,7 +434,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -478,7 +456,6 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@@ -23,14 +23,12 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
|
|||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver)
|
public function __construct(IDibiDriver $driver)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -54,7 +52,6 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -88,7 +85,6 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -115,7 +111,6 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -54,7 +54,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
private $buffered;
|
private $buffered;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -66,13 +65,12 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
mysqli_report(MYSQLI_REPORT_OFF);
|
mysqli_report(MYSQLI_REPORT_OFF);
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
@@ -80,12 +78,14 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// default values
|
// default values
|
||||||
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
$config += array(
|
||||||
if (!isset($config['timezone'])) $config['timezone'] = date('P');
|
'charset' => 'utf8',
|
||||||
if (!isset($config['username'])) $config['username'] = ini_get('mysqli.default_user');
|
'timezone' => date('P'),
|
||||||
if (!isset($config['password'])) $config['password'] = ini_get('mysqli.default_pw');
|
'username' => ini_get('mysqli.default_user'),
|
||||||
if (!isset($config['socket'])) $config['socket'] = ini_get('mysqli.default_socket');
|
'password' => ini_get('mysqli.default_pw'),
|
||||||
if (!isset($config['port'])) $config['port'] = NULL;
|
'socket' => ini_get('mysqli.default_socket'),
|
||||||
|
'port' => NULL,
|
||||||
|
);
|
||||||
if (!isset($config['host'])) {
|
if (!isset($config['host'])) {
|
||||||
$host = ini_get('mysqli.default_host');
|
$host = ini_get('mysqli.default_host');
|
||||||
if ($host) {
|
if ($host) {
|
||||||
@@ -141,7 +141,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -152,7 +151,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -172,7 +170,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves information about the most recently executed query.
|
* Retrieves information about the most recently executed query.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -181,7 +178,9 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
{
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
preg_match_all('#(.+?): +(\d+) *#', mysqli_info($this->connection), $matches, PREG_SET_ORDER);
|
preg_match_all('#(.+?): +(\d+) *#', mysqli_info($this->connection), $matches, PREG_SET_ORDER);
|
||||||
if (preg_last_error()) throw new DibiPcreException;
|
if (preg_last_error()) {
|
||||||
|
throw new DibiPcreException;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($matches as $m) {
|
foreach ($matches as $m) {
|
||||||
$res[$m[1]] = (int) $m[2];
|
$res[$m[1]] = (int) $m[2];
|
||||||
@@ -190,7 +189,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -201,7 +199,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -212,7 +209,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -225,7 +221,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -238,7 +233,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -251,7 +245,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mysqli
|
* @return mysqli
|
||||||
@@ -262,7 +255,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -273,7 +265,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param mysqli_result
|
* @param mysqli_result
|
||||||
@@ -287,11 +278,9 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -302,31 +291,30 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
return "'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
return "'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||||
|
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
return '`' . str_replace('`', '``', $value) . '`';
|
return '`' . str_replace('`', '``', $value) . '`';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -340,7 +328,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -357,29 +344,23 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
if ($limit >= 0 || $offset > 0) {
|
||||||
|
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
|
||||||
// see http://dev.mysql.com/doc/refman/5.0/en/select.html
|
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
||||||
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||||
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -390,7 +371,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -404,7 +384,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -416,7 +395,6 @@ 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
|
||||||
@@ -432,7 +410,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -444,7 +421,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -478,7 +454,6 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mysqli_result
|
* @return mysqli_result
|
||||||
|
@@ -42,7 +42,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
private $row = 0;
|
private $row = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -54,21 +53,22 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
} else {
|
} else {
|
||||||
// default values
|
// default values
|
||||||
if (!isset($config['username'])) $config['username'] = ini_get('odbc.default_user');
|
$config += array(
|
||||||
if (!isset($config['password'])) $config['password'] = ini_get('odbc.default_pw');
|
'username' => ini_get('odbc.default_user'),
|
||||||
if (!isset($config['dsn'])) $config['dsn'] = ini_get('odbc.default_db');
|
'password' => ini_get('odbc.default_pw'),
|
||||||
|
'dsn' => ini_get('odbc.default_db'),
|
||||||
|
);
|
||||||
|
|
||||||
if (empty($config['persistent'])) {
|
if (empty($config['persistent'])) {
|
||||||
$this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']); // intentionally @
|
$this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']); // intentionally @
|
||||||
@@ -83,7 +83,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -94,7 +93,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -116,7 +114,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -127,7 +124,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -138,7 +134,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -153,7 +148,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -169,7 +163,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -185,7 +178,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is in transaction?
|
* Is in transaction?
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -196,7 +188,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -207,7 +198,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -218,7 +208,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -232,11 +221,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -247,29 +234,28 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "'" . str_replace("'", "''", $value) . "'";
|
return "'" . str_replace("'", "''", $value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("#m/d/Y#") : date("#m/d/Y#", $value);
|
return $value instanceof DateTime ? $value->format("#m/d/Y#") : date("#m/d/Y#", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("#m/d/Y H:i:s#") : date("#m/d/Y H:i:s#", $value);
|
return $value instanceof DateTime ? $value->format("#m/d/Y H:i:s#") : date("#m/d/Y H:i:s#", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -283,7 +269,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -300,30 +285,26 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
// offset support is missing
|
// offset support is missing
|
||||||
if ($limit >= 0) {
|
if ($limit >= 0) {
|
||||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($offset) throw new DibiNotSupportedException('Offset is not implemented in driver odbc.');
|
if ($offset) {
|
||||||
|
throw new DibiNotSupportedException('Offset is not implemented in driver odbc.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -334,7 +315,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -346,7 +326,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -358,7 +337,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
return odbc_fetch_array($this->resultSet, ++$this->row);
|
return odbc_fetch_array($this->resultSet, ++$this->row);
|
||||||
} else {
|
} else {
|
||||||
$set = $this->resultSet;
|
$set = $this->resultSet;
|
||||||
if (!odbc_fetch_row($set, ++$this->row)) return FALSE;
|
if (!odbc_fetch_row($set, ++$this->row)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$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);
|
||||||
@@ -367,7 +348,6 @@ 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
|
||||||
@@ -380,7 +360,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -392,7 +371,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -413,7 +391,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -425,11 +402,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* IDibiReflector ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -451,7 +426,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -478,7 +452,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -490,7 +463,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -45,7 +45,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
private $fmtDate, $fmtDateTime;
|
private $fmtDate, $fmtDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -57,13 +56,12 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
$foo = & $config['charset'];
|
$foo = & $config['charset'];
|
||||||
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
||||||
@@ -84,7 +82,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -95,7 +92,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -121,7 +117,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -132,7 +127,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -144,7 +138,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -156,7 +149,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -173,7 +165,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -190,7 +181,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -201,7 +191,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -212,7 +201,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -226,11 +214,9 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -241,30 +227,29 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested
|
return "'" . str_replace("'", "''", $value) . "'"; // TODO: not tested
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
// @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
|
// @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
|
||||||
return '"' . str_replace('"', '""', $value) . '"';
|
return '"' . str_replace('"', '""', $value) . '"';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -279,7 +264,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -296,19 +280,17 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($offset > 0) {
|
if ($offset > 0) {
|
||||||
// see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
|
// see http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
|
||||||
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t ' . ($limit >= 0 ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '') . ') WHERE "__rnum" > '. (int) $offset;
|
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
|
||||||
|
. ($limit >= 0 ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
|
||||||
|
. ') WHERE "__rnum" > '. (int) $offset;
|
||||||
|
|
||||||
} elseif ($limit >= 0) {
|
} elseif ($limit >= 0) {
|
||||||
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
|
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
|
||||||
@@ -316,11 +298,9 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -331,7 +311,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -342,7 +321,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -354,7 +332,6 @@ 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
|
||||||
@@ -366,7 +343,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -378,7 +354,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -399,7 +374,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -411,11 +385,9 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* IDibiReflector ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -436,7 +408,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -448,7 +419,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -460,7 +430,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -43,7 +43,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
private $driverName;
|
private $driverName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -55,13 +54,12 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
$foo = & $config['dsn'];
|
$foo = & $config['dsn'];
|
||||||
$foo = & $config['options'];
|
$foo = & $config['options'];
|
||||||
@@ -85,7 +83,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -96,7 +93,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -131,7 +127,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -142,7 +137,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -153,7 +147,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -169,7 +162,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -185,7 +177,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -201,7 +192,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return PDO
|
* @return PDO
|
||||||
@@ -212,7 +202,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -220,20 +209,19 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
public function getReflector()
|
public function getReflector()
|
||||||
{
|
{
|
||||||
switch ($this->driverName) {
|
switch ($this->driverName) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
return new DibiMySqlReflector($this);
|
return new DibiMySqlReflector($this);
|
||||||
|
|
||||||
case 'sqlite':
|
case 'sqlite':
|
||||||
case 'sqlite2':
|
case 'sqlite2':
|
||||||
return new DibiSqliteReflector($this);
|
return new DibiSqliteReflector($this);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new DibiNotSupportedException;
|
throw new DibiNotSupportedException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param PDOStatement
|
* @param PDOStatement
|
||||||
@@ -247,11 +235,9 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -262,52 +248,51 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
return $this->connection->quote($value, PDO::PARAM_STR);
|
return $this->connection->quote($value, PDO::PARAM_STR);
|
||||||
|
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return $this->connection->quote($value, PDO::PARAM_LOB);
|
return $this->connection->quote($value, PDO::PARAM_LOB);
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
switch ($this->driverName) {
|
switch ($this->driverName) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
return '`' . str_replace('`', '``', $value) . '`';
|
return '`' . str_replace('`', '``', $value) . '`';
|
||||||
|
|
||||||
case 'pgsql':
|
case 'pgsql':
|
||||||
return '"' . str_replace('"', '""', $value) . '"';
|
return '"' . str_replace('"', '""', $value) . '"';
|
||||||
|
|
||||||
case 'sqlite':
|
case 'sqlite':
|
||||||
case 'sqlite2':
|
case 'sqlite2':
|
||||||
return '[' . strtr($value, '[]', ' ') . ']';
|
return '[' . strtr($value, '[]', ' ') . ']';
|
||||||
|
|
||||||
case 'odbc':
|
case 'odbc':
|
||||||
case 'oci': // TODO: not tested
|
case 'oci': // TODO: not tested
|
||||||
case 'mssql':
|
case 'mssql':
|
||||||
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
|
||||||
|
|
||||||
case 'sqlsrv':
|
case 'sqlsrv':
|
||||||
return '[' . str_replace(']', ']]', $value) . ']';
|
return '[' . str_replace(']', ']]', $value) . ']';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
case dibi::BOOL:
|
||||||
|
return $this->connection->quote($value, PDO::PARAM_BOOL);
|
||||||
|
|
||||||
|
case dibi::DATE:
|
||||||
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
|
case dibi::DATETIME:
|
||||||
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $value;
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
|
||||||
|
|
||||||
case dibi::BOOL:
|
|
||||||
return $this->connection->quote($value, PDO::PARAM_BOOL);
|
|
||||||
|
|
||||||
case dibi::DATE:
|
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
|
||||||
|
|
||||||
case dibi::DATETIME:
|
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -320,7 +305,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -337,62 +321,64 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
if ($limit < 0 && $offset < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->driverName) {
|
switch ($this->driverName) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
$sql .= ' LIMIT ' . ($limit < 0 ? '18446744073709551615' : (int) $limit)
|
||||||
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
. ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||||
break;
|
|
||||||
|
|
||||||
case 'pgsql':
|
|
||||||
if ($limit >= 0) $sql .= ' LIMIT ' . (int) $limit;
|
|
||||||
if ($offset > 0) $sql .= ' OFFSET ' . (int) $offset;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'sqlite':
|
|
||||||
case 'sqlite2':
|
|
||||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'oci':
|
|
||||||
if ($offset > 0) {
|
|
||||||
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t ' . ($limit >= 0 ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '') . ') WHERE "__rnum" > '. (int) $offset;
|
|
||||||
} elseif ($limit >= 0) {
|
|
||||||
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'odbc':
|
|
||||||
case 'mssql':
|
|
||||||
case 'sqlsrv':
|
|
||||||
if ($offset < 1) {
|
|
||||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
// intentionally break omitted
|
|
||||||
|
|
||||||
default:
|
case 'pgsql':
|
||||||
throw new DibiNotSupportedException('PDO or driver does not support applying limit or offset.');
|
if ($limit >= 0) {
|
||||||
|
$sql .= ' LIMIT ' . (int) $limit;
|
||||||
|
}
|
||||||
|
if ($offset > 0) {
|
||||||
|
$sql .= ' OFFSET ' . (int) $offset;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'sqlite':
|
||||||
|
case 'sqlite2':
|
||||||
|
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'oci':
|
||||||
|
if ($offset > 0) {
|
||||||
|
$sql = 'SELECT * FROM (SELECT t.*, ROWNUM AS "__rnum" FROM (' . $sql . ') t '
|
||||||
|
. ($limit >= 0 ? 'WHERE ROWNUM <= ' . ((int) $offset + (int) $limit) : '')
|
||||||
|
. ') WHERE "__rnum" > '. (int) $offset;
|
||||||
|
} elseif ($limit >= 0) {
|
||||||
|
$sql = 'SELECT * FROM (' . $sql . ') WHERE ROWNUM <= ' . (int) $limit;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'odbc':
|
||||||
|
case 'mssql':
|
||||||
|
case 'sqlsrv':
|
||||||
|
if ($offset < 1) {
|
||||||
|
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// intentionally break omitted
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new DibiNotSupportedException('PDO or driver does not support applying limit or offset.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -403,7 +389,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -415,7 +400,6 @@ 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
|
||||||
@@ -427,7 +411,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -438,7 +421,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -472,7 +454,6 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return PDOStatement
|
* @return PDOStatement
|
||||||
|
@@ -43,7 +43,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
private $escMethod = FALSE;
|
private $escMethod = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -55,19 +54,20 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!isset($config['charset'])) $config['charset'] = 'utf8';
|
$config += array(
|
||||||
|
'charset' => 'utf8',
|
||||||
|
);
|
||||||
if (isset($config['string'])) {
|
if (isset($config['string'])) {
|
||||||
$string = $config['string'];
|
$string = $config['string'];
|
||||||
} else {
|
} else {
|
||||||
@@ -75,7 +75,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
DibiConnection::alias($config, 'user', 'username');
|
DibiConnection::alias($config, 'user', 'username');
|
||||||
DibiConnection::alias($config, 'dbname', 'database');
|
DibiConnection::alias($config, 'dbname', 'database');
|
||||||
foreach (array('host','hostaddr','port','dbname','user','password','connect_timeout','options','sslmode','service') as $key) {
|
foreach (array('host','hostaddr','port','dbname','user','password','connect_timeout','options','sslmode','service') as $key) {
|
||||||
if (isset($config[$key])) $string .= $key . '=' . $config[$key] . ' ';
|
if (isset($config[$key])) {
|
||||||
|
$string .= $key . '=' . $config[$key] . ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +112,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -121,7 +122,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -145,7 +145,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -156,7 +155,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -170,14 +168,15 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
$res = $this->query("SELECT CURRVAL('$sequence')");
|
$res = $this->query("SELECT CURRVAL('$sequence')");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$res) return FALSE;
|
if (!$res) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$row = $res->fetch(FALSE);
|
$row = $res->fetch(FALSE);
|
||||||
return is_array($row) ? $row[0] : FALSE;
|
return is_array($row) ? $row[0] : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -190,7 +189,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -203,7 +201,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -216,7 +213,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is in transaction?
|
* Is in transaction?
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -227,7 +223,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -238,7 +233,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -249,7 +243,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -263,11 +256,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -278,46 +269,45 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
if ($this->escMethod) {
|
if ($this->escMethod) {
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
throw new DibiException('Lost connection to server.');
|
throw new DibiException('Lost connection to server.');
|
||||||
|
}
|
||||||
|
return "'" . pg_escape_string($this->connection, $value) . "'";
|
||||||
|
} else {
|
||||||
|
return "'" . pg_escape_string($value) . "'";
|
||||||
}
|
}
|
||||||
return "'" . pg_escape_string($this->connection, $value) . "'";
|
|
||||||
} else {
|
|
||||||
return "'" . pg_escape_string($value) . "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
if ($this->escMethod) {
|
if ($this->escMethod) {
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
throw new DibiException('Lost connection to server.');
|
throw new DibiException('Lost connection to server.');
|
||||||
|
}
|
||||||
|
return "'" . pg_escape_bytea($this->connection, $value) . "'";
|
||||||
|
} else {
|
||||||
|
return "'" . pg_escape_bytea($value) . "'";
|
||||||
}
|
}
|
||||||
return "'" . pg_escape_bytea($this->connection, $value) . "'";
|
|
||||||
} else {
|
|
||||||
return "'" . pg_escape_bytea($value) . "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
|
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
|
||||||
return '"' . str_replace('"', '""', $value) . '"';
|
return '"' . str_replace('"', '""', $value) . '"';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 'TRUE' : 'FALSE';
|
return $value ? 'TRUE' : 'FALSE';
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d'") : date("'Y-m-d'", $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
return $value instanceof DateTime ? $value->format("'Y-m-d H:i:s'") : date("'Y-m-d H:i:s'", $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -337,7 +327,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -354,29 +343,25 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit >= 0)
|
if ($limit >= 0) {
|
||||||
$sql .= ' LIMIT ' . (int) $limit;
|
$sql .= ' LIMIT ' . (int) $limit;
|
||||||
|
}
|
||||||
|
|
||||||
if ($offset > 0)
|
if ($offset > 0) {
|
||||||
$sql .= ' OFFSET ' . (int) $offset;
|
$sql .= ' OFFSET ' . (int) $offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -387,7 +372,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -398,7 +382,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -410,7 +393,6 @@ 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
|
||||||
@@ -422,7 +404,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -434,7 +415,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -457,7 +437,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -469,11 +448,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* IDibiReflector ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -502,7 +479,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -543,7 +519,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -585,7 +560,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -46,7 +46,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
private $dbcharset, $charset;
|
private $dbcharset, $charset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -58,13 +57,12 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
DibiConnection::alias($config, 'database', 'file');
|
DibiConnection::alias($config, 'database', 'file');
|
||||||
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
||||||
@@ -93,7 +91,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -104,7 +101,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -127,7 +123,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -138,7 +133,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -149,7 +143,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -162,7 +155,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -175,7 +167,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -188,7 +179,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -199,7 +189,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -210,7 +199,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param SQLite3Result
|
* @param SQLite3Result
|
||||||
@@ -224,11 +212,9 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -239,31 +225,30 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
return "'" . $this->connection->escapeString($value) . "'";
|
return "'" . $this->connection->escapeString($value) . "'";
|
||||||
|
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "X'" . bin2hex((string) $value) . "'";
|
return "X'" . bin2hex((string) $value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
return '[' . strtr($value, '[]', ' ') . ']';
|
return '[' . strtr($value, '[]', ' ') . ']';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -277,7 +262,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -294,26 +278,21 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
if ($limit >= 0 || $offset > 0) {
|
||||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
$sql .= ' LIMIT ' . (int) $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -324,7 +303,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -336,7 +314,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -360,7 +337,6 @@ 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
|
||||||
@@ -373,7 +349,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -385,7 +360,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -407,7 +381,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -419,11 +392,9 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* user defined functions ****************d*g**/
|
/********************* user defined functions ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an user defined function for use in SQL statements.
|
* Registers an user defined function for use in SQL statements.
|
||||||
* @param string function name
|
* @param string function name
|
||||||
@@ -437,7 +408,6 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an aggregating user defined function for use in SQL statements.
|
* Registers an aggregating user defined function for use in SQL statements.
|
||||||
* @param string function name
|
* @param string function name
|
||||||
|
@@ -48,7 +48,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
private $dbcharset, $charset;
|
private $dbcharset, $charset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws DibiNotSupportedException
|
* @throws DibiNotSupportedException
|
||||||
*/
|
*/
|
||||||
@@ -60,13 +59,12 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array & $config)
|
||||||
{
|
{
|
||||||
DibiConnection::alias($config, 'database', 'file');
|
DibiConnection::alias($config, 'database', 'file');
|
||||||
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
$this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
|
||||||
@@ -95,7 +93,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -106,7 +103,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -134,7 +130,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
@@ -145,7 +140,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
@@ -156,7 +150,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -169,7 +162,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -182,7 +174,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -195,7 +186,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection resource.
|
* Returns the connection resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -206,7 +196,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection reflector.
|
* Returns the connection reflector.
|
||||||
* @return IDibiReflector
|
* @return IDibiReflector
|
||||||
@@ -217,7 +206,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set driver factory.
|
* Result set driver factory.
|
||||||
* @param resource
|
* @param resource
|
||||||
@@ -231,11 +219,9 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* SQL ****************d*g**/
|
/********************* SQL ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes data for use in a SQL statement.
|
* Encodes data for use in a SQL statement.
|
||||||
* @param mixed value
|
* @param mixed value
|
||||||
@@ -246,29 +232,28 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
public function escape($value, $type)
|
public function escape($value, $type)
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case dibi::TEXT:
|
case dibi::TEXT:
|
||||||
case dibi::BINARY:
|
case dibi::BINARY:
|
||||||
return "'" . sqlite_escape_string($value) . "'";
|
return "'" . sqlite_escape_string($value) . "'";
|
||||||
|
|
||||||
case dibi::IDENTIFIER:
|
case dibi::IDENTIFIER:
|
||||||
return '[' . strtr($value, '[]', ' ') . ']';
|
return '[' . strtr($value, '[]', ' ') . ']';
|
||||||
|
|
||||||
case dibi::BOOL:
|
case dibi::BOOL:
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
|
|
||||||
case dibi::DATE:
|
case dibi::DATE:
|
||||||
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
return $value instanceof DateTime ? $value->format($this->fmtDate) : date($this->fmtDate, $value);
|
||||||
|
|
||||||
case dibi::DATETIME:
|
case dibi::DATETIME:
|
||||||
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
return $value instanceof DateTime ? $value->format($this->fmtDateTime) : date($this->fmtDateTime, $value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidArgumentException('Unsupported type.');
|
throw new InvalidArgumentException('Unsupported type.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encodes string for use in a LIKE statement.
|
* Encodes string for use in a LIKE statement.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -281,7 +266,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes data from result set.
|
* Decodes data from result set.
|
||||||
* @param string value
|
* @param string value
|
||||||
@@ -298,26 +282,21 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function applyLimit(&$sql, $limit, $offset)
|
public function applyLimit(& $sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
if ($limit < 0 && $offset < 1) return;
|
if ($limit >= 0 || $offset > 0) {
|
||||||
$sql .= ' LIMIT ' . $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
$sql .= ' LIMIT ' . (int) $limit . ($offset > 0 ? ' OFFSET ' . (int) $offset : '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* result set ****************d*g**/
|
/********************* result set ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -331,7 +310,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position and moves the internal cursor to the next position.
|
* Fetches the row at current position and moves the internal cursor to the next position.
|
||||||
* @param bool TRUE for associative array, FALSE for numeric
|
* @param bool TRUE for associative array, FALSE for numeric
|
||||||
@@ -355,7 +333,6 @@ 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
|
||||||
@@ -371,7 +348,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -382,7 +358,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a result set.
|
* Returns metadata for all columns in a result set.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -405,7 +380,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the result set resource.
|
* Returns the result set resource.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -416,11 +390,9 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* user defined functions ****************d*g**/
|
/********************* user defined functions ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an user defined function for use in SQL statements.
|
* Registers an user defined function for use in SQL statements.
|
||||||
* @param string function name
|
* @param string function name
|
||||||
@@ -434,7 +406,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an aggregating user defined function for use in SQL statements.
|
* Registers an aggregating user defined function for use in SQL statements.
|
||||||
* @param string function name
|
* @param string function name
|
||||||
|
@@ -23,14 +23,12 @@ class DibiSqliteReflector extends DibiObject implements IDibiReflector
|
|||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver)
|
public function __construct(IDibiDriver $driver)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -51,7 +49,6 @@ class DibiSqliteReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all columns in a table.
|
* Returns metadata for all columns in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -87,7 +84,6 @@ class DibiSqliteReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all indexes in a table.
|
* Returns metadata for all indexes in a table.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -139,7 +135,6 @@ class DibiSqliteReflector extends DibiObject implements IDibiReflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns metadata for all foreign keys in a table.
|
* Returns metadata for all foreign keys in a table.
|
||||||
* @param string
|
* @param string
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi connection.
|
* dibi connection.
|
||||||
*
|
*
|
||||||
@@ -45,7 +44,6 @@ class DibiConnection extends DibiObject
|
|||||||
private $substitutes;
|
private $substitutes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection options: (see driver-specific options too)
|
* Connection options: (see driver-specific options too)
|
||||||
* - lazy (bool) => if TRUE, connection will be established only when required
|
* - lazy (bool) => if TRUE, connection will be established only when required
|
||||||
@@ -139,7 +137,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically frees the resources allocated for this result set.
|
* Automatically frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -151,7 +148,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database.
|
* Connects to a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -171,7 +167,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -183,7 +178,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns TRUE when connection was established.
|
* Returns TRUE when connection was established.
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -194,7 +188,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns configuration variable. If no $key is passed, returns the entire array.
|
* Returns configuration variable. If no $key is passed, returns the entire array.
|
||||||
* @see self::__construct
|
* @see self::__construct
|
||||||
@@ -216,7 +209,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply configuration alias or default values.
|
* Apply configuration alias or default values.
|
||||||
* @param array connect configuration
|
* @param array connect configuration
|
||||||
@@ -224,10 +216,12 @@ class DibiConnection extends DibiObject
|
|||||||
* @param string alias key
|
* @param string alias key
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function alias(&$config, $key, $alias)
|
public static function alias(& $config, $key, $alias)
|
||||||
{
|
{
|
||||||
$foo = & $config;
|
$foo = & $config;
|
||||||
foreach (explode('|', $key) as $key) $foo = & $foo[$key];
|
foreach (explode('|', $key) as $key) {
|
||||||
|
$foo = & $foo[$key];
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($foo) && isset($config[$alias])) {
|
if (!isset($foo) && isset($config[$alias])) {
|
||||||
$foo = $config[$alias];
|
$foo = $config[$alias];
|
||||||
@@ -236,7 +230,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the driver and connects to a database in lazy mode.
|
* Returns the driver and connects to a database in lazy mode.
|
||||||
* @return IDibiDriver
|
* @return IDibiDriver
|
||||||
@@ -248,7 +241,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates (translates) and executes SQL query.
|
* Generates (translates) and executes SQL query.
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -262,7 +254,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates SQL query.
|
* Generates SQL query.
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -276,7 +267,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and prints SQL query.
|
* Generates and prints SQL query.
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -300,7 +290,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates (translates) and returns SQL query as DibiDataSource.
|
* Generates (translates) and returns SQL query as DibiDataSource.
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -314,7 +303,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates SQL query.
|
* Generates SQL query.
|
||||||
* @param array
|
* @param array
|
||||||
@@ -327,7 +315,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL query.
|
* Executes the SQL query.
|
||||||
* @param string SQL statement.
|
* @param string SQL statement.
|
||||||
@@ -359,7 +346,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int number of rows
|
* @return int number of rows
|
||||||
@@ -369,12 +355,13 @@ class DibiConnection extends DibiObject
|
|||||||
{
|
{
|
||||||
$this->connected || $this->connect();
|
$this->connected || $this->connect();
|
||||||
$rows = $this->driver->getAffectedRows();
|
$rows = $this->driver->getAffectedRows();
|
||||||
if (!is_int($rows) || $rows < 0) throw new DibiException('Cannot retrieve number of affected rows.');
|
if (!is_int($rows) || $rows < 0) {
|
||||||
|
throw new DibiException('Cannot retrieve number of affected rows.');
|
||||||
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows. Alias for getAffectedRows().
|
* Gets the number of affected rows. Alias for getAffectedRows().
|
||||||
* @return int number of rows
|
* @return int number of rows
|
||||||
@@ -386,7 +373,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @param string optional sequence name
|
* @param string optional sequence name
|
||||||
@@ -397,12 +383,13 @@ class DibiConnection extends DibiObject
|
|||||||
{
|
{
|
||||||
$this->connected || $this->connect();
|
$this->connected || $this->connect();
|
||||||
$id = $this->driver->getInsertId($sequence);
|
$id = $this->driver->getInsertId($sequence);
|
||||||
if ($id < 1) throw new DibiException('Cannot retrieve last generated ID.');
|
if ($id < 1) {
|
||||||
|
throw new DibiException('Cannot retrieve last generated ID.');
|
||||||
|
}
|
||||||
return (int) $id;
|
return (int) $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
|
* Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
|
||||||
* @param string optional sequence name
|
* @param string optional sequence name
|
||||||
@@ -415,7 +402,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -436,7 +422,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits statements in a transaction.
|
* Commits statements in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -457,7 +442,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback changes in a transaction.
|
* Rollback changes in a transaction.
|
||||||
* @param string optional savepoint name
|
* @param string optional savepoint name
|
||||||
@@ -478,7 +462,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set factory.
|
* Result set factory.
|
||||||
* @param IDibiResultDriver
|
* @param IDibiResultDriver
|
||||||
@@ -492,11 +475,9 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* fluent SQL builders ****************d*g**/
|
/********************* fluent SQL builders ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
*/
|
*/
|
||||||
@@ -506,7 +487,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string column name
|
* @param string column name
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
@@ -518,7 +498,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string table
|
* @param string table
|
||||||
* @param array
|
* @param array
|
||||||
@@ -533,7 +512,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string table
|
* @param string table
|
||||||
* @param array
|
* @param array
|
||||||
@@ -551,7 +529,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string table
|
* @param string table
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
@@ -562,11 +539,9 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* substitutions ****************d*g**/
|
/********************* substitutions ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns substitution hashmap.
|
* Returns substitution hashmap.
|
||||||
* @return DibiHashMap
|
* @return DibiHashMap
|
||||||
@@ -577,7 +552,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides substitution.
|
* Provides substitution.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -588,7 +562,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Substitution callback.
|
* Substitution callback.
|
||||||
*/
|
*/
|
||||||
@@ -598,11 +571,9 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* shortcuts ****************d*g**/
|
/********************* shortcuts ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
* Executes SQL query and fetch result - shortcut for query() & fetch().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -616,7 +587,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch results - shortcut for query() & fetchAll().
|
* Executes SQL query and fetch results - shortcut for query() & fetchAll().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -630,7 +600,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
|
* Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -644,7 +613,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
|
* Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
|
||||||
* @param array|mixed one or more arguments
|
* @param array|mixed one or more arguments
|
||||||
@@ -658,11 +626,9 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* misc ****************d*g**/
|
/********************* misc ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import SQL dump from file - extreme fast!
|
* Import SQL dump from file - extreme fast!
|
||||||
* @param string filename
|
* @param string filename
|
||||||
@@ -698,7 +664,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a information about the current database.
|
* Gets a information about the current database.
|
||||||
* @return DibiDatabaseInfo
|
* @return DibiDatabaseInfo
|
||||||
@@ -710,7 +675,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents unserialization.
|
* Prevents unserialization.
|
||||||
*/
|
*/
|
||||||
@@ -720,7 +684,6 @@ class DibiConnection extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents serialization.
|
* Prevents serialization.
|
||||||
*/
|
*/
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of IDataSource for dibi.
|
* Default implementation of IDataSource for dibi.
|
||||||
*
|
*
|
||||||
@@ -55,7 +54,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
private $limit;
|
private $limit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string SQL command or table or view name, as data source
|
* @param string SQL command or table or view name, as data source
|
||||||
* @param DibiConnection connection
|
* @param DibiConnection connection
|
||||||
@@ -71,12 +69,11 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects columns to query.
|
* Selects columns to query.
|
||||||
* @param string|array column name or array of column names
|
* @param string|array column name or array of column names
|
||||||
* @param string column alias
|
* @param string column alias
|
||||||
* @return DibiDataSource provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function select($col, $as = NULL)
|
public function select($col, $as = NULL)
|
||||||
{
|
{
|
||||||
@@ -90,11 +87,10 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds conditions to query.
|
* Adds conditions to query.
|
||||||
* @param mixed conditions
|
* @param mixed conditions
|
||||||
* @return DibiDataSource provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function where($cond)
|
public function where($cond)
|
||||||
{
|
{
|
||||||
@@ -109,12 +105,11 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects columns to order by.
|
* Selects columns to order by.
|
||||||
* @param string|array column name or array of column names
|
* @param string|array column name or array of column names
|
||||||
* @param string sorting direction
|
* @param string sorting direction
|
||||||
* @return DibiDataSource provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function orderBy($row, $sorting = 'ASC')
|
public function orderBy($row, $sorting = 'ASC')
|
||||||
{
|
{
|
||||||
@@ -128,12 +123,11 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limits number of rows.
|
* Limits number of rows.
|
||||||
* @param int limit
|
* @param int limit
|
||||||
* @param int offset
|
* @param int offset
|
||||||
* @return DibiDataSource provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function applyLimit($limit, $offset = NULL)
|
public function applyLimit($limit, $offset = NULL)
|
||||||
{
|
{
|
||||||
@@ -144,7 +138,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the dibi connection.
|
* Returns the dibi connection.
|
||||||
* @return DibiConnection
|
* @return DibiConnection
|
||||||
@@ -155,11 +148,9 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* executing ****************d*g**/
|
/********************* executing ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns (and queries) DibiResult.
|
* Returns (and queries) DibiResult.
|
||||||
* @return DibiResult
|
* @return DibiResult
|
||||||
@@ -173,7 +164,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiResultIterator
|
* @return DibiResultIterator
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +173,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates, executes SQL query and fetches the single row.
|
* Generates, executes SQL query and fetches the single row.
|
||||||
* @return DibiRow|FALSE array on success, FALSE if no next record
|
* @return DibiRow|FALSE array on success, FALSE if no next record
|
||||||
@@ -194,7 +183,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like fetch(), but returns only first field.
|
* 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
|
||||||
@@ -205,7 +193,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table.
|
* Fetches all records from table.
|
||||||
* @return array
|
* @return array
|
||||||
@@ -216,7 +203,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table and returns associative tree.
|
* Fetches all records from table and returns associative tree.
|
||||||
* @param string associative descriptor
|
* @param string associative descriptor
|
||||||
@@ -228,7 +214,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table like $key => $value pairs.
|
* Fetches all records from table like $key => $value pairs.
|
||||||
* @param string associative key
|
* @param string associative key
|
||||||
@@ -241,7 +226,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discards the internal cache.
|
* Discards the internal cache.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -252,11 +236,9 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* exporting ****************d*g**/
|
/********************* exporting ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this data source wrapped in DibiFluent object.
|
* Returns this data source wrapped in DibiFluent object.
|
||||||
* @return DibiFluent
|
* @return DibiFluent
|
||||||
@@ -267,7 +249,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this data source wrapped in DibiDataSource object.
|
* Returns this data source wrapped in DibiDataSource object.
|
||||||
* @return DibiDataSource
|
* @return DibiDataSource
|
||||||
@@ -278,7 +259,6 @@ class DibiDataSource extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns SQL query.
|
* Returns SQL query.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -299,11 +279,9 @@ FROM %SQL', $this->sql, '
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* counting ****************d*g**/
|
/********************* counting ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a given data source.
|
* Returns the number of rows in a given data source.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -321,7 +299,6 @@ FROM %SQL', $this->sql, '
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a given data source.
|
* Returns the number of rows in a given data source.
|
||||||
* @return int
|
* @return int
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection metadata class for a database.
|
* Reflection metadata class for a database.
|
||||||
*
|
*
|
||||||
@@ -33,7 +32,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
private $tables;
|
private $tables;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiReflector $reflector, $name)
|
public function __construct(IDibiReflector $reflector, $name)
|
||||||
{
|
{
|
||||||
$this->reflector = $reflector;
|
$this->reflector = $reflector;
|
||||||
@@ -41,7 +39,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +48,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of DibiTableInfo
|
* @return array of DibiTableInfo
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +58,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of string
|
* @return array of string
|
||||||
*/
|
*/
|
||||||
@@ -77,7 +72,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return DibiTableInfo
|
* @return DibiTableInfo
|
||||||
@@ -95,7 +89,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -107,7 +100,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -124,8 +116,6 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection metadata class for a database table.
|
* Reflection metadata class for a database table.
|
||||||
*
|
*
|
||||||
@@ -164,7 +154,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
private $primaryKey;
|
private $primaryKey;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiReflector $reflector, array $info)
|
public function __construct(IDibiReflector $reflector, array $info)
|
||||||
{
|
{
|
||||||
$this->reflector = $reflector;
|
$this->reflector = $reflector;
|
||||||
@@ -173,7 +162,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +171,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -193,7 +180,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of DibiColumnInfo
|
* @return array of DibiColumnInfo
|
||||||
*/
|
*/
|
||||||
@@ -204,7 +190,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of string
|
* @return array of string
|
||||||
*/
|
*/
|
||||||
@@ -219,7 +204,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return DibiColumnInfo
|
* @return DibiColumnInfo
|
||||||
@@ -237,7 +221,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -249,7 +232,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of DibiForeignKeyInfo
|
* @return array of DibiForeignKeyInfo
|
||||||
*/
|
*/
|
||||||
@@ -260,7 +242,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of DibiIndexInfo
|
* @return array of DibiIndexInfo
|
||||||
*/
|
*/
|
||||||
@@ -271,7 +252,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiIndexInfo
|
* @return DibiIndexInfo
|
||||||
*/
|
*/
|
||||||
@@ -282,7 +262,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -297,7 +276,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -319,7 +297,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -331,8 +308,6 @@ class DibiTableInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection metadata class for a result set.
|
* Reflection metadata class for a result set.
|
||||||
*
|
*
|
||||||
@@ -354,14 +329,12 @@ class DibiResultInfo extends DibiObject
|
|||||||
private $names;
|
private $names;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiResultDriver $driver)
|
public function __construct(IDibiResultDriver $driver)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of DibiColumnInfo
|
* @return array of DibiColumnInfo
|
||||||
*/
|
*/
|
||||||
@@ -372,7 +345,6 @@ class DibiResultInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool
|
* @param bool
|
||||||
* @return array of string
|
* @return array of string
|
||||||
@@ -388,7 +360,6 @@ class DibiResultInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return DibiColumnInfo
|
* @return DibiColumnInfo
|
||||||
@@ -406,7 +377,6 @@ class DibiResultInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -418,7 +388,6 @@ class DibiResultInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -436,8 +405,6 @@ class DibiResultInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection metadata class for a table or result set column.
|
* Reflection metadata class for a table or result set column.
|
||||||
*
|
*
|
||||||
@@ -467,7 +434,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
private $info;
|
private $info;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiReflector $reflector = NULL, array $info)
|
public function __construct(IDibiReflector $reflector = NULL, array $info)
|
||||||
{
|
{
|
||||||
$this->reflector = $reflector;
|
$this->reflector = $reflector;
|
||||||
@@ -475,7 +441,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -485,7 +450,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -495,7 +459,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -505,7 +468,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiTableInfo
|
* @return DibiTableInfo
|
||||||
*/
|
*/
|
||||||
@@ -518,7 +480,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -528,7 +489,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -538,7 +498,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -548,7 +507,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -558,7 +516,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -568,7 +525,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -578,7 +534,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -588,7 +543,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
@@ -598,7 +552,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -609,7 +562,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Heuristic type detection.
|
* Heuristic type detection.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -639,7 +591,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
@@ -654,8 +605,6 @@ class DibiColumnInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection metadata class for a foreign key.
|
* Reflection metadata class for a foreign key.
|
||||||
*
|
*
|
||||||
@@ -675,7 +624,6 @@ class DibiForeignKeyInfo extends DibiObject
|
|||||||
private $references;
|
private $references;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($name, array $references)
|
public function __construct($name, array $references)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@@ -683,7 +631,6 @@ class DibiForeignKeyInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -693,7 +640,6 @@ class DibiForeignKeyInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -705,8 +651,6 @@ class DibiForeignKeyInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection metadata class for a index or primary key.
|
* Reflection metadata class for a index or primary key.
|
||||||
*
|
*
|
||||||
@@ -730,7 +674,6 @@ class DibiIndexInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -740,7 +683,6 @@ class DibiIndexInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -750,7 +692,6 @@ class DibiIndexInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -760,7 +701,6 @@ class DibiIndexInfo extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DateTime with serialization and timestamp support for PHP 5.2.
|
* DateTime with serialization and timestamp support for PHP 5.2.
|
||||||
*
|
*
|
||||||
@@ -33,7 +32,6 @@ class DibiDateTime extends DateTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function modifyClone($modify = '')
|
public function modifyClone($modify = '')
|
||||||
{
|
{
|
||||||
$dolly = clone($this);
|
$dolly = clone($this);
|
||||||
@@ -41,7 +39,6 @@ class DibiDateTime extends DateTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function modify($modify)
|
public function modify($modify)
|
||||||
{
|
{
|
||||||
parent::modify($modify);
|
parent::modify($modify);
|
||||||
@@ -49,7 +46,6 @@ class DibiDateTime extends DateTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
$this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());
|
$this->fix = array($this->format('Y-m-d H:i:s'), $this->getTimezone()->getName());
|
||||||
@@ -57,7 +53,6 @@ class DibiDateTime extends DateTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __wakeup()
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
|
$this->__construct($this->fix[0], new DateTimeZone($this->fix[1]));
|
||||||
@@ -65,21 +60,18 @@ class DibiDateTime extends DateTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getTimestamp()
|
public function getTimestamp()
|
||||||
{
|
{
|
||||||
return (int) $this->format('U');
|
return (int) $this->format('U');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function setTimestamp($timestamp)
|
public function setTimestamp($timestamp)
|
||||||
{
|
{
|
||||||
return $this->__construct(date('Y-m-d H:i:s', $timestamp), new DateTimeZone($this->getTimezone()->getName())); // getTimeZone() crashes in PHP 5.2.6
|
return $this->__construct(date('Y-m-d H:i:s', $timestamp), new DateTimeZone($this->getTimezone()->getName())); // getTimeZone() crashes in PHP 5.2.6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return $this->format('Y-m-d H:i:s');
|
return $this->format('Y-m-d H:i:s');
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Profiler & logger event.
|
* Profiler & logger event.
|
||||||
*
|
*
|
||||||
@@ -54,7 +53,6 @@ class DibiEvent
|
|||||||
public $source;
|
public $source;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(DibiConnection $connection, $type, $sql = NULL)
|
public function __construct(DibiConnection $connection, $type, $sql = NULL)
|
||||||
{
|
{
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
@@ -85,7 +83,6 @@ class DibiEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function done($result = NULL)
|
public function done($result = NULL)
|
||||||
{
|
{
|
||||||
$this->result = $result;
|
$this->result = $result;
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi common exception.
|
* dibi common exception.
|
||||||
*
|
*
|
||||||
@@ -36,7 +35,6 @@ class DibiException extends Exception
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string The SQL passed to the constructor
|
* @return string The SQL passed to the constructor
|
||||||
*/
|
*/
|
||||||
@@ -46,7 +44,6 @@ class DibiException extends Exception
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string string represenation of exception with SQL command
|
* @return string string represenation of exception with SQL command
|
||||||
*/
|
*/
|
||||||
@@ -58,8 +55,6 @@ class DibiException extends Exception
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* database server exception.
|
* database server exception.
|
||||||
*
|
*
|
||||||
@@ -72,12 +67,10 @@ class DibiDriverException extends DibiException
|
|||||||
/********************* error catching ****************d*g**/
|
/********************* error catching ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private static $errorMsg;
|
private static $errorMsg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts catching potential errors/warnings.
|
* Starts catching potential errors/warnings.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -89,7 +82,6 @@ class DibiDriverException extends DibiException
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns catched error/warning message.
|
* Returns catched error/warning message.
|
||||||
* @param string catched message
|
* @param string catched message
|
||||||
@@ -104,7 +96,6 @@ class DibiDriverException extends DibiException
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal error handler. Do not call directly.
|
* Internal error handler. Do not call directly.
|
||||||
* @internal
|
* @internal
|
||||||
@@ -124,8 +115,6 @@ class DibiDriverException extends DibiException
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PCRE exception.
|
* PCRE exception.
|
||||||
*
|
*
|
||||||
@@ -149,7 +138,6 @@ class DibiPcreException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package dibi
|
* @package dibi
|
||||||
*/
|
*/
|
||||||
@@ -157,7 +145,6 @@ class DibiNotImplementedException extends DibiException
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package dibi
|
* @package dibi
|
||||||
*/
|
*/
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi file logger.
|
* dibi file logger.
|
||||||
*
|
*
|
||||||
@@ -26,7 +25,6 @@ class DibiFileLogger extends DibiObject
|
|||||||
public $filter;
|
public $filter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($file, $filter = NULL)
|
public function __construct($file, $filter = NULL)
|
||||||
{
|
{
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
@@ -34,7 +32,6 @@ class DibiFileLogger extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After event notification.
|
* After event notification.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -46,7 +43,9 @@ class DibiFileLogger extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$handle = fopen($this->file, 'a');
|
$handle = fopen($this->file, 'a');
|
||||||
if (!$handle) return; // or throw exception?
|
if (!$handle) {
|
||||||
|
return; // or throw exception?
|
||||||
|
}
|
||||||
flock($handle, LOCK_EX);
|
flock($handle, LOCK_EX);
|
||||||
|
|
||||||
if ($event->result instanceof Exception) {
|
if ($event->result instanceof Exception) {
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi FirePHP logger.
|
* dibi FirePHP logger.
|
||||||
*
|
*
|
||||||
@@ -38,7 +37,6 @@ class DibiFirePhpLogger extends DibiObject
|
|||||||
private static $fireTable = array(array('Time', 'SQL Statement', 'Rows', 'Connection'));
|
private static $fireTable = array(array('Time', 'SQL Statement', 'Rows', 'Connection'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@@ -48,14 +46,12 @@ class DibiFirePhpLogger extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct($filter = NULL)
|
public function __construct($filter = NULL)
|
||||||
{
|
{
|
||||||
$this->filter = $filter ? (int) $filter : DibiEvent::QUERY;
|
$this->filter = $filter ? (int) $filter : DibiEvent::QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After event notification.
|
* After event notification.
|
||||||
* @return void
|
* @return void
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi SQL builder via fluent interfaces. EXPERIMENTAL!
|
* dibi SQL builder via fluent interfaces. EXPERIMENTAL!
|
||||||
*
|
*
|
||||||
@@ -101,7 +100,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
private static $normalizer;
|
private static $normalizer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DibiConnection
|
* @param DibiConnection
|
||||||
*/
|
*/
|
||||||
@@ -115,12 +113,11 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends new argument to the clause.
|
* Appends new argument to the clause.
|
||||||
* @param string clause name
|
* @param string clause name
|
||||||
* @param array arguments
|
* @param array arguments
|
||||||
* @return DibiFluent provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __call($clause, $args)
|
public function __call($clause, $args)
|
||||||
{
|
{
|
||||||
@@ -205,11 +202,10 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch to a clause.
|
* Switch to a clause.
|
||||||
* @param string clause name
|
* @param string clause name
|
||||||
* @return DibiFluent provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function clause($clause, $remove = FALSE)
|
public function clause($clause, $remove = FALSE)
|
||||||
{
|
{
|
||||||
@@ -227,11 +223,10 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a clause.
|
* Removes a clause.
|
||||||
* @param string clause name
|
* @param string clause name
|
||||||
* @return DibiFluent provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function removeClause($clause)
|
public function removeClause($clause)
|
||||||
{
|
{
|
||||||
@@ -240,12 +235,11 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a SQL flag.
|
* Change a SQL flag.
|
||||||
* @param string flag name
|
* @param string flag name
|
||||||
* @param bool value
|
* @param bool value
|
||||||
* @return DibiFluent provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setFlag($flag, $value = TRUE)
|
public function setFlag($flag, $value = TRUE)
|
||||||
{
|
{
|
||||||
@@ -259,7 +253,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a flag set?
|
* Is a flag set?
|
||||||
* @param string flag name
|
* @param string flag name
|
||||||
@@ -271,7 +264,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns SQL command.
|
* Returns SQL command.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -282,7 +274,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the dibi connection.
|
* Returns the dibi connection.
|
||||||
* @return DibiConnection
|
* @return DibiConnection
|
||||||
@@ -293,12 +284,11 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds DibiResult setup.
|
* Adds DibiResult setup.
|
||||||
* @param string method
|
* @param string method
|
||||||
* @param mixed args
|
* @param mixed args
|
||||||
* @return DibiFluent provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setupResult($method)
|
public function setupResult($method)
|
||||||
{
|
{
|
||||||
@@ -307,11 +297,9 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* executing ****************d*g**/
|
/********************* executing ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and executes SQL query.
|
* Generates and executes SQL query.
|
||||||
* @param mixed what to return?
|
* @param mixed what to return?
|
||||||
@@ -325,7 +313,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates, executes SQL query and fetches the single row.
|
* Generates, executes SQL query and fetches the single row.
|
||||||
* @return DibiRow|FALSE array on success, FALSE if no next record
|
* @return DibiRow|FALSE array on success, FALSE if no next record
|
||||||
@@ -340,7 +327,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like fetch(), but returns only first field.
|
* 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
|
||||||
@@ -355,7 +341,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table.
|
* Fetches all records from table.
|
||||||
* @param int offset
|
* @param int offset
|
||||||
@@ -368,7 +353,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table and returns associative tree.
|
* Fetches all records from table and returns associative tree.
|
||||||
* @param string associative descriptor
|
* @param string associative descriptor
|
||||||
@@ -380,7 +364,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table like $key => $value pairs.
|
* Fetches all records from table like $key => $value pairs.
|
||||||
* @param string associative key
|
* @param string associative key
|
||||||
@@ -393,7 +376,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required by the IteratorAggregate interface.
|
* Required by the IteratorAggregate interface.
|
||||||
* @param int offset
|
* @param int offset
|
||||||
@@ -406,7 +388,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates and prints SQL query or it's part.
|
* Generates and prints SQL query or it's part.
|
||||||
* @param string clause name
|
* @param string clause name
|
||||||
@@ -418,7 +399,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -430,7 +410,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiResult
|
* @return DibiResult
|
||||||
*/
|
*/
|
||||||
@@ -444,11 +423,9 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* exporting ****************d*g**/
|
/********************* exporting ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return DibiDataSource
|
* @return DibiDataSource
|
||||||
*/
|
*/
|
||||||
@@ -458,7 +435,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns SQL query.
|
* Returns SQL query.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -473,7 +449,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates parameters for DibiTranslator.
|
* Generates parameters for DibiTranslator.
|
||||||
* @param string clause name
|
* @param string clause name
|
||||||
@@ -499,7 +474,9 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
if ($clause === $this->command && $this->flags) {
|
if ($clause === $this->command && $this->flags) {
|
||||||
$args[] = implode(' ', array_keys($this->flags));
|
$args[] = implode(' ', array_keys($this->flags));
|
||||||
}
|
}
|
||||||
foreach ($statement as $arg) $args[] = $arg;
|
foreach ($statement as $arg) {
|
||||||
|
$args[] = $arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +484,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format camelCase clause name to UPPER CASE.
|
* Format camelCase clause name to UPPER CASE.
|
||||||
* @param string
|
* @param string
|
||||||
@@ -524,7 +500,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
// remove references
|
// remove references
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazy cached storage.
|
* Lazy cached storage.
|
||||||
*
|
*
|
||||||
@@ -29,7 +28,6 @@ abstract class DibiHashMapBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function setCallback($callback)
|
public function setCallback($callback)
|
||||||
{
|
{
|
||||||
if (!is_callable($callback)) {
|
if (!is_callable($callback)) {
|
||||||
@@ -40,7 +38,6 @@ abstract class DibiHashMapBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getCallback()
|
public function getCallback()
|
||||||
{
|
{
|
||||||
return $this->callback;
|
return $this->callback;
|
||||||
@@ -49,7 +46,6 @@ abstract class DibiHashMapBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazy cached storage.
|
* Lazy cached storage.
|
||||||
*
|
*
|
||||||
@@ -68,7 +64,6 @@ final class DibiHashMap extends DibiHashMapBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __get($nm)
|
public function __get($nm)
|
||||||
{
|
{
|
||||||
if ($nm == '') {
|
if ($nm == '') {
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL literal value.
|
* SQL literal value.
|
||||||
*
|
*
|
||||||
@@ -28,7 +27,6 @@ class DibiLiteral extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DibiObject is the ultimate ancestor of all instantiable classes.
|
* DibiObject is the ultimate ancestor of all instantiable classes.
|
||||||
*
|
*
|
||||||
@@ -58,7 +57,6 @@ abstract class DibiObject
|
|||||||
private static $extMethods;
|
private static $extMethods;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the class of this object.
|
* Returns the name of the class of this object.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -69,7 +67,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to reflection.
|
* Access to reflection.
|
||||||
* @return \ReflectionObject
|
* @return \ReflectionObject
|
||||||
@@ -80,7 +77,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call to undefined method.
|
* Call to undefined method.
|
||||||
* @param string method name
|
* @param string method name
|
||||||
@@ -125,7 +121,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call to undefined static method.
|
* Call to undefined static method.
|
||||||
* @param string method name (in lower case!)
|
* @param string method name (in lower case!)
|
||||||
@@ -140,7 +135,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adding method to class.
|
* Adding method to class.
|
||||||
* @param string method name
|
* @param string method name
|
||||||
@@ -158,7 +152,9 @@ abstract class DibiObject
|
|||||||
self::$extMethods[$pair[1]][''] = NULL;
|
self::$extMethods[$pair[1]][''] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($name === NULL) return NULL;
|
if ($name === NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
@@ -202,14 +198,13 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns property value. Do not call directly.
|
* Returns property value. Do not call directly.
|
||||||
* @param string property name
|
* @param string property name
|
||||||
* @return mixed property value
|
* @return mixed property value
|
||||||
* @throws \LogicException if the property is not defined.
|
* @throws \LogicException if the property is not defined.
|
||||||
*/
|
*/
|
||||||
public function &__get($name)
|
public function & __get($name)
|
||||||
{
|
{
|
||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
|
|
||||||
@@ -222,8 +217,8 @@ abstract class DibiObject
|
|||||||
$m = 'get' . $name;
|
$m = 'get' . $name;
|
||||||
if (self::hasAccessor($class, $m)) {
|
if (self::hasAccessor($class, $m)) {
|
||||||
// ampersands:
|
// ampersands:
|
||||||
// - uses &__get() because declaration should be forward compatible (e.g. with Nette\Web\Html)
|
// - uses & __get() because declaration should be forward compatible (e.g. with Nette\Web\Html)
|
||||||
// - doesn't call &$this->$m because user could bypass property setter by: $x = & $obj->property; $x = 'new value';
|
// - doesn't call & $this->$m because user could bypass property setter by: $x = & $obj->property; $x = 'new value';
|
||||||
$val = $this->$m();
|
$val = $this->$m();
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
@@ -239,7 +234,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets value of a property. Do not call directly.
|
* Sets value of a property. Do not call directly.
|
||||||
* @param string property name
|
* @param string property name
|
||||||
@@ -274,7 +268,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is property defined?
|
* Is property defined?
|
||||||
* @param string property name
|
* @param string property name
|
||||||
@@ -287,7 +280,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to undeclared property.
|
* Access to undeclared property.
|
||||||
* @param string property name
|
* @param string property name
|
||||||
@@ -301,7 +293,6 @@ abstract class DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has property an accessor?
|
* Has property an accessor?
|
||||||
* @param string class name
|
* @param string class name
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi result set.
|
* dibi result set.
|
||||||
*
|
*
|
||||||
@@ -61,7 +60,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
private $formats = array();
|
private $formats = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IDibiResultDriver
|
* @param IDibiResultDriver
|
||||||
*/
|
*/
|
||||||
@@ -72,7 +70,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +79,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees the resources allocated for this result set.
|
* Frees the resources allocated for this result set.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -96,7 +92,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safe access to property $driver.
|
* Safe access to property $driver.
|
||||||
* @return IDibiResultDriver
|
* @return IDibiResultDriver
|
||||||
@@ -112,11 +107,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* rows ****************d*g**/
|
/********************* rows ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -129,7 +122,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required by the Countable interface.
|
* Required by the Countable interface.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -140,7 +132,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
@@ -151,7 +142,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows in a result set. Alias for getRowCount().
|
* Returns the number of rows in a result set. Alias for getRowCount().
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@@ -163,7 +153,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required by the IteratorAggregate interface.
|
* Required by the IteratorAggregate interface.
|
||||||
* @return DibiResultIterator
|
* @return DibiResultIterator
|
||||||
@@ -177,15 +166,13 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* fetching rows ****************d*g**/
|
/********************* fetching rows ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set fetched object class. This class should extend the DibiRow class.
|
* Set fetched object class. This class should extend the DibiRow class.
|
||||||
* @param string
|
* @param string
|
||||||
* @return DibiResult provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRowClass($class)
|
public function setRowClass($class)
|
||||||
{
|
{
|
||||||
@@ -194,7 +181,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns fetched object class name.
|
* Returns fetched object class name.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -205,11 +191,10 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a factory to create fetched object instances. These should extend the DibiRow class.
|
* Set a factory to create fetched object instances. These should extend the DibiRow class.
|
||||||
* @param callback
|
* @param callback
|
||||||
* @return DibiResult provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRowFactory($callback)
|
public function setRowFactory($callback)
|
||||||
{
|
{
|
||||||
@@ -218,7 +203,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the row at current position, process optional type conversion.
|
* Fetches the row at current position, process optional type conversion.
|
||||||
* and moves the internal cursor to the next position
|
* and moves the internal cursor to the next position
|
||||||
@@ -241,7 +225,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like fetch(), but returns only first field.
|
* 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
|
||||||
@@ -258,7 +241,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table.
|
* Fetches all records from table.
|
||||||
* @param int offset
|
* @param int offset
|
||||||
@@ -270,11 +252,15 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
$limit = $limit === NULL ? -1 : (int) $limit;
|
$limit = $limit === NULL ? -1 : (int) $limit;
|
||||||
$this->seek((int) $offset);
|
$this->seek((int) $offset);
|
||||||
$row = $this->fetch();
|
$row = $this->fetch();
|
||||||
if (!$row) return array(); // empty result set
|
if (!$row) {
|
||||||
|
return array(); // empty result set
|
||||||
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
do {
|
do {
|
||||||
if ($limit === 0) break;
|
if ($limit === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$limit--;
|
$limit--;
|
||||||
$data[] = $row;
|
$data[] = $row;
|
||||||
} while ($row = $this->fetch());
|
} while ($row = $this->fetch());
|
||||||
@@ -283,7 +269,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table and returns associative tree.
|
* Fetches all records from table and returns associative tree.
|
||||||
* Examples:
|
* Examples:
|
||||||
@@ -303,7 +288,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
|
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
$row = $this->fetch();
|
$row = $this->fetch();
|
||||||
if (!$row) return array(); // empty result set
|
if (!$row) {
|
||||||
|
return array(); // empty result set
|
||||||
|
}
|
||||||
|
|
||||||
$data = NULL;
|
$data = NULL;
|
||||||
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
$assoc = preg_split('#(\[\]|->|=|\|)#', $assoc, NULL, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
@@ -362,7 +349,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -370,7 +356,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
$row = $this->fetch();
|
$row = $this->fetch();
|
||||||
if (!$row) return array(); // empty result set
|
if (!$row) {
|
||||||
|
return array(); // empty result set
|
||||||
|
}
|
||||||
|
|
||||||
$data = NULL;
|
$data = NULL;
|
||||||
$assoc = explode(',', $assoc);
|
$assoc = explode(',', $assoc);
|
||||||
@@ -435,7 +423,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all records from table like $key => $value pairs.
|
* Fetches all records from table like $key => $value pairs.
|
||||||
* @param string associative key
|
* @param string associative key
|
||||||
@@ -447,7 +434,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
$row = $this->fetch();
|
$row = $this->fetch();
|
||||||
if (!$row) return array(); // empty result set
|
if (!$row) {
|
||||||
|
return array(); // empty result set
|
||||||
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
@@ -493,11 +482,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* column types ****************d*g**/
|
/********************* column types ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autodetect column types.
|
* Autodetect column types.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -513,7 +500,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts values to specified type and format.
|
* Converts values to specified type and format.
|
||||||
* @param array
|
* @param array
|
||||||
@@ -561,12 +547,11 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define column type.
|
* Define column type.
|
||||||
* @param string column
|
* @param string column
|
||||||
* @param string type (use constant Dibi::*)
|
* @param string type (use constant Dibi::*)
|
||||||
* @return DibiResult provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
final public function setType($col, $type)
|
final public function setType($col, $type)
|
||||||
{
|
{
|
||||||
@@ -575,7 +560,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns column type.
|
* Returns column type.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -586,12 +570,11 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets data format.
|
* Sets data format.
|
||||||
* @param string type (use constant Dibi::*)
|
* @param string type (use constant Dibi::*)
|
||||||
* @param string format
|
* @param string format
|
||||||
* @return DibiResult provides a fluent interface
|
* @return self
|
||||||
*/
|
*/
|
||||||
final public function setFormat($type, $format)
|
final public function setFormat($type, $format)
|
||||||
{
|
{
|
||||||
@@ -600,7 +583,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns data format.
|
* Returns data format.
|
||||||
* @return string
|
* @return string
|
||||||
@@ -611,11 +593,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* meta info ****************d*g**/
|
/********************* meta info ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a meta information about the current result set.
|
* Returns a meta information about the current result set.
|
||||||
* @return DibiResultInfo
|
* @return DibiResultInfo
|
||||||
@@ -629,7 +609,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -639,7 +618,6 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public function getColumnNames($fullNames = FALSE)
|
public function getColumnNames($fullNames = FALSE)
|
||||||
{
|
{
|
||||||
@@ -648,11 +626,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* misc tools ****************d*g**/
|
/********************* misc tools ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays complete result set as HTML or text table for debug purposes.
|
* Displays complete result set as HTML or text table for debug purposes.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -668,7 +644,7 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
if ($i === 0) {
|
if ($i === 0) {
|
||||||
foreach ($row as $col => $foo) {
|
foreach ($row as $col => $foo) {
|
||||||
$len = mb_strlen($col);
|
$len = mb_strlen($col);
|
||||||
if ($len > $maxLen) $maxLen = $len;
|
$maxLen = max($len, $maxLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,7 +663,9 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i === 0) echo "empty result set\n";
|
if ($i === 0) {
|
||||||
|
echo "empty result set\n";
|
||||||
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* External result set iterator.
|
* External result set iterator.
|
||||||
*
|
*
|
||||||
@@ -47,7 +46,6 @@ class DibiResultIterator implements Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewinds the iterator to the first element.
|
* Rewinds the iterator to the first element.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -60,7 +58,6 @@ class DibiResultIterator implements Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the key of the current element.
|
* Returns the key of the current element.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -71,7 +68,6 @@ class DibiResultIterator implements Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current element.
|
* Returns the current element.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -82,7 +78,6 @@ class DibiResultIterator implements Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves forward to next element.
|
* Moves forward to next element.
|
||||||
* @return void
|
* @return void
|
||||||
@@ -94,7 +89,6 @@ class DibiResultIterator implements Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if there is a current element after calls to rewind() or next().
|
* Checks if there is a current element after calls to rewind() or next().
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -105,7 +99,6 @@ class DibiResultIterator implements Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required by the Countable interface.
|
* Required by the Countable interface.
|
||||||
* @return int
|
* @return int
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result set single row.
|
* Result set single row.
|
||||||
*
|
*
|
||||||
@@ -22,18 +21,18 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
|
|
||||||
public function __construct($arr)
|
public function __construct($arr)
|
||||||
{
|
{
|
||||||
foreach ($arr as $k => $v) $this->$k = $v;
|
foreach ($arr as $k => $v) {
|
||||||
|
$this->$k = $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
return (array) $this;
|
return (array) $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts value to DateTime object.
|
* Converts value to DateTime object.
|
||||||
* @param string key
|
* @param string key
|
||||||
@@ -53,7 +52,6 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts value to UNIX timestamp.
|
* Converts value to UNIX timestamp.
|
||||||
* @param string key
|
* @param string key
|
||||||
@@ -69,7 +67,6 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts value to boolean.
|
* Converts value to boolean.
|
||||||
* @param string key
|
* @param string key
|
||||||
@@ -82,7 +79,6 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public function asDate($key, $format = NULL)
|
public function asDate($key, $format = NULL)
|
||||||
{
|
{
|
||||||
@@ -95,46 +91,39 @@ class DibiRow implements ArrayAccess, IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* interfaces ArrayAccess, Countable & IteratorAggregate ****************d*g**/
|
/********************* interfaces ArrayAccess, Countable & IteratorAggregate ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final public function count()
|
final public function count()
|
||||||
{
|
{
|
||||||
return count((array) $this);
|
return count((array) $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final public function getIterator()
|
final public function getIterator()
|
||||||
{
|
{
|
||||||
return new ArrayIterator($this);
|
return new ArrayIterator($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final public function offsetSet($nm, $val)
|
final public function offsetSet($nm, $val)
|
||||||
{
|
{
|
||||||
$this->$nm = $val;
|
$this->$nm = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final public function offsetGet($nm)
|
final public function offsetGet($nm)
|
||||||
{
|
{
|
||||||
return $this->$nm;
|
return $this->$nm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final public function offsetExists($nm)
|
final public function offsetExists($nm)
|
||||||
{
|
{
|
||||||
return isset($this->$nm);
|
return isset($this->$nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final public function offsetUnset($nm)
|
final public function offsetUnset($nm)
|
||||||
{
|
{
|
||||||
unset($this->$nm);
|
unset($this->$nm);
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi SQL translator.
|
* dibi SQL translator.
|
||||||
*
|
*
|
||||||
@@ -53,14 +52,12 @@ final class DibiTranslator extends DibiObject
|
|||||||
private $identifiers;
|
private $identifiers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(DibiConnection $connection)
|
public function __construct(DibiConnection $connection)
|
||||||
{
|
{
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates SQL.
|
* Generates SQL.
|
||||||
* @param array
|
* @param array
|
||||||
@@ -94,8 +91,7 @@ final class DibiTranslator extends DibiObject
|
|||||||
|
|
||||||
// iterate
|
// iterate
|
||||||
$sql = array();
|
$sql = array();
|
||||||
while ($cursor < count($this->args))
|
while ($cursor < count($this->args)) {
|
||||||
{
|
|
||||||
$arg = $this->args[$cursor];
|
$arg = $this->args[$cursor];
|
||||||
$cursor++;
|
$cursor++;
|
||||||
|
|
||||||
@@ -126,7 +122,9 @@ final class DibiTranslator extends DibiObject
|
|||||||
array($this, 'cb'),
|
array($this, 'cb'),
|
||||||
substr($arg, $toSkip)
|
substr($arg, $toSkip)
|
||||||
);
|
);
|
||||||
if (preg_last_error()) throw new DibiPcreException;
|
if (preg_last_error()) {
|
||||||
|
throw new DibiPcreException;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -148,7 +146,9 @@ final class DibiTranslator extends DibiObject
|
|||||||
$commandIns = $commandIns === 'INSERT' || $commandIns === 'REPLAC';
|
$commandIns = $commandIns === 'INSERT' || $commandIns === 'REPLAC';
|
||||||
$sql[] = $this->formatValue($arg, $commandIns ? 'v' : 'a');
|
$sql[] = $this->formatValue($arg, $commandIns ? 'v' : 'a');
|
||||||
} else {
|
} else {
|
||||||
if ($lastArr === $cursor - 1) $sql[] = ',';
|
if ($lastArr === $cursor - 1) {
|
||||||
|
$sql[] = ',';
|
||||||
|
}
|
||||||
$sql[] = $this->formatValue($arg, $commandIns ? 'l' : 'a');
|
$sql[] = $this->formatValue($arg, $commandIns ? 'l' : 'a');
|
||||||
}
|
}
|
||||||
$lastArr = $cursor;
|
$lastArr = $cursor;
|
||||||
@@ -161,7 +161,9 @@ final class DibiTranslator extends DibiObject
|
|||||||
} // while
|
} // while
|
||||||
|
|
||||||
|
|
||||||
if ($comment) $sql[] = "*/";
|
if ($comment) {
|
||||||
|
$sql[] = "*/";
|
||||||
|
}
|
||||||
|
|
||||||
$sql = implode(' ', $sql);
|
$sql = implode(' ', $sql);
|
||||||
|
|
||||||
@@ -178,7 +180,6 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply modifier to single value.
|
* Apply modifier to single value.
|
||||||
* @param mixed
|
* @param mixed
|
||||||
@@ -199,131 +200,131 @@ final class DibiTranslator extends DibiObject
|
|||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$vx = $kx = array();
|
$vx = $kx = array();
|
||||||
switch ($modifier) {
|
switch ($modifier) {
|
||||||
case 'and':
|
case 'and':
|
||||||
case 'or': // key=val AND key IS NULL AND ...
|
case 'or': // key=val AND key IS NULL AND ...
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
return '1=1';
|
return '1=1';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if (is_string($k)) {
|
if (is_string($k)) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
$k = $this->identifiers->{$pair[0]} . ' ';
|
$k = $this->identifiers->{$pair[0]} . ' ';
|
||||||
if (!isset($pair[1])) {
|
if (!isset($pair[1])) {
|
||||||
$v = $this->formatValue($v, FALSE);
|
$v = $this->formatValue($v, FALSE);
|
||||||
$vx[] = $k . ($v === 'NULL' ? 'IS ' : '= ') . $v;
|
$vx[] = $k . ($v === 'NULL' ? 'IS ' : '= ') . $v;
|
||||||
|
|
||||||
} elseif ($pair[1] === 'ex') { // TODO: this will be removed
|
} elseif ($pair[1] === 'ex') { // TODO: this will be removed
|
||||||
$vx[] = $k . $this->formatValue($v, 'ex');
|
$vx[] = $k . $this->formatValue($v, 'ex');
|
||||||
|
|
||||||
} else {
|
|
||||||
$v = $this->formatValue($v, $pair[1]);
|
|
||||||
if ($pair[1] === 'l' || $pair[1] === 'in') {
|
|
||||||
$op = 'IN ';
|
|
||||||
} elseif (strpos($pair[1], 'like') !== FALSE) {
|
|
||||||
$op = 'LIKE ';
|
|
||||||
} elseif ($v === 'NULL') {
|
|
||||||
$op = 'IS ';
|
|
||||||
} else {
|
} else {
|
||||||
$op = '= ';
|
$v = $this->formatValue($v, $pair[1]);
|
||||||
|
if ($pair[1] === 'l' || $pair[1] === 'in') {
|
||||||
|
$op = 'IN ';
|
||||||
|
} elseif (strpos($pair[1], 'like') !== FALSE) {
|
||||||
|
$op = 'LIKE ';
|
||||||
|
} elseif ($v === 'NULL') {
|
||||||
|
$op = 'IS ';
|
||||||
|
} else {
|
||||||
|
$op = '= ';
|
||||||
|
}
|
||||||
|
$vx[] = $k . $op . $v;
|
||||||
}
|
}
|
||||||
$vx[] = $k . $op . $v;
|
|
||||||
|
} else {
|
||||||
|
$vx[] = $this->formatValue($v, 'ex');
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
$vx[] = $this->formatValue($v, 'ex');
|
|
||||||
}
|
}
|
||||||
}
|
return '(' . implode(') ' . strtoupper($modifier) . ' (', $vx) . ')';
|
||||||
return '(' . implode(') ' . strtoupper($modifier) . ' (', $vx) . ')';
|
|
||||||
|
|
||||||
case 'n': // key, key, ... identifier names
|
case 'n': // key, key, ... identifier names
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if (is_string($k)) {
|
if (is_string($k)) {
|
||||||
$vx[] = $this->identifiers->$k . (empty($v) ? '' : ' AS ' . $this->identifiers->$v);
|
$vx[] = $this->identifiers->$k . (empty($v) ? '' : ' AS ' . $this->identifiers->$v);
|
||||||
} else {
|
} else {
|
||||||
$pair = explode('%', $v, 2); // split into identifier & modifier
|
$pair = explode('%', $v, 2); // split into identifier & modifier
|
||||||
$vx[] = $this->identifiers->{$pair[0]};
|
$vx[] = $this->identifiers->{$pair[0]};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return implode(', ', $vx);
|
||||||
return implode(', ', $vx);
|
|
||||||
|
|
||||||
|
|
||||||
case 'a': // key=val, key=val, ...
|
case 'a': // key=val, key=val, ...
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
$vx[] = $this->identifiers->{$pair[0]} . '='
|
$vx[] = $this->identifiers->{$pair[0]} . '='
|
||||||
. $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
. $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
||||||
}
|
}
|
||||||
return implode(', ', $vx);
|
return implode(', ', $vx);
|
||||||
|
|
||||||
|
|
||||||
case 'in':// replaces scalar %in modifier!
|
case 'in':// replaces scalar %in modifier!
|
||||||
case 'l': // (val, val, ...)
|
case 'l': // (val, val, ...)
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
||||||
}
|
}
|
||||||
return '(' . (($vx || $modifier === 'l') ? implode(', ', $vx) : 'NULL') . ')';
|
return '(' . (($vx || $modifier === 'l') ? implode(', ', $vx) : 'NULL') . ')';
|
||||||
|
|
||||||
|
|
||||||
case 'v': // (key, key, ...) VALUES (val, val, ...)
|
case 'v': // (key, key, ...) VALUES (val, val, ...)
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
$kx[] = $this->identifiers->{$pair[0]};
|
$kx[] = $this->identifiers->{$pair[0]};
|
||||||
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
$vx[] = $this->formatValue($v, isset($pair[1]) ? $pair[1] : (is_array($v) ? 'ex' : FALSE));
|
||||||
}
|
}
|
||||||
return '(' . implode(', ', $kx) . ') VALUES (' . implode(', ', $vx) . ')';
|
return '(' . implode(', ', $kx) . ') VALUES (' . implode(', ', $vx) . ')';
|
||||||
|
|
||||||
case 'm': // (key, key, ...) VALUES (val, val, ...), (val, val, ...), ...
|
case 'm': // (key, key, ...) VALUES (val, val, ...), (val, val, ...), ...
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if (is_array($v)) {
|
if (is_array($v)) {
|
||||||
if (isset($proto)) {
|
if (isset($proto)) {
|
||||||
if ($proto !== array_keys($v)) {
|
if ($proto !== array_keys($v)) {
|
||||||
$this->hasError = TRUE;
|
$this->hasError = TRUE;
|
||||||
return '**Multi-insert array "' . $k . '" is different.**';
|
return '**Multi-insert array "' . $k . '" is different.**';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$proto = array_keys($v);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$proto = array_keys($v);
|
$this->hasError = TRUE;
|
||||||
|
return '**Unexpected type ' . gettype($v) . '**';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pair = explode('%', $k, 2); // split into identifier & modifier
|
||||||
|
$kx[] = $this->identifiers->{$pair[0]};
|
||||||
|
foreach ($v as $k2 => $v2) {
|
||||||
|
$vx[$k2][] = $this->formatValue($v2, isset($pair[1]) ? $pair[1] : (is_array($v2) ? 'ex' : FALSE));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$this->hasError = TRUE;
|
|
||||||
return '**Unexpected type ' . gettype($v) . '**';
|
|
||||||
}
|
}
|
||||||
|
foreach ($vx as $k => $v) {
|
||||||
$pair = explode('%', $k, 2); // split into identifier & modifier
|
$vx[$k] = '(' . implode(', ', $v) . ')';
|
||||||
$kx[] = $this->identifiers->{$pair[0]};
|
|
||||||
foreach ($v as $k2 => $v2) {
|
|
||||||
$vx[$k2][] = $this->formatValue($v2, isset($pair[1]) ? $pair[1] : (is_array($v2) ? 'ex' : FALSE));
|
|
||||||
}
|
}
|
||||||
}
|
return '(' . implode(', ', $kx) . ') VALUES ' . implode(', ', $vx);
|
||||||
foreach ($vx as $k => $v) {
|
|
||||||
$vx[$k] = '(' . implode(', ', $v) . ')';
|
|
||||||
}
|
|
||||||
return '(' . implode(', ', $kx) . ') VALUES ' . implode(', ', $vx);
|
|
||||||
|
|
||||||
case 'by': // key ASC, key DESC
|
case 'by': // key ASC, key DESC
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if (is_array($v)) {
|
if (is_array($v)) {
|
||||||
$vx[] = $this->formatValue($v, 'ex');
|
$vx[] = $this->formatValue($v, 'ex');
|
||||||
} elseif (is_string($k)) {
|
} elseif (is_string($k)) {
|
||||||
$v = (is_string($v) && strncasecmp($v, 'd', 1)) || $v > 0 ? 'ASC' : 'DESC';
|
$v = (is_string($v) && strncasecmp($v, 'd', 1)) || $v > 0 ? 'ASC' : 'DESC';
|
||||||
$vx[] = $this->identifiers->$k . ' ' . $v;
|
$vx[] = $this->identifiers->$k . ' ' . $v;
|
||||||
} else {
|
} else {
|
||||||
$vx[] = $this->identifiers->$v;
|
$vx[] = $this->identifiers->$v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return implode(', ', $vx);
|
||||||
return implode(', ', $vx);
|
|
||||||
|
|
||||||
case 'ex':
|
case 'ex':
|
||||||
case 'sql':
|
case 'sql':
|
||||||
$translator = new self($this->connection);
|
$translator = new self($this->connection);
|
||||||
return $translator->translate($value);
|
return $translator->translate($value);
|
||||||
|
|
||||||
default: // value, value, value - all with the same modifier
|
default: // value, value, value - all with the same modifier
|
||||||
foreach ($value as $v) {
|
foreach ($value as $v) {
|
||||||
$vx[] = $this->formatValue($v, $modifier);
|
$vx[] = $this->formatValue($v, $modifier);
|
||||||
}
|
}
|
||||||
return implode(', ', $vx);
|
return implode(', ', $vx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,94 +337,98 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($modifier) {
|
switch ($modifier) {
|
||||||
case 's': // string
|
case 's': // string
|
||||||
case 'bin':// binary
|
case 'bin':// binary
|
||||||
case 'b': // boolean
|
case 'b': // boolean
|
||||||
return $value === NULL ? 'NULL' : $this->driver->escape($value, $modifier);
|
return $value === NULL ? 'NULL' : $this->driver->escape($value, $modifier);
|
||||||
|
|
||||||
case 'sN': // string or NULL
|
case 'sN': // string or NULL
|
||||||
case 'sn':
|
case 'sn':
|
||||||
return $value == '' ? 'NULL' : $this->driver->escape($value, dibi::TEXT); // notice two equal signs
|
return $value == '' ? 'NULL' : $this->driver->escape($value, dibi::TEXT); // notice two equal signs
|
||||||
|
|
||||||
case 'iN': // signed int or NULL
|
case 'iN': // signed int or NULL
|
||||||
case 'in': // deprecated
|
case 'in': // deprecated
|
||||||
if ($value == '') $value = NULL;
|
if ($value == '') {
|
||||||
// intentionally break omitted
|
$value = NULL;
|
||||||
|
|
||||||
case 'i': // signed int
|
|
||||||
case 'u': // unsigned int, ignored
|
|
||||||
// support for long numbers - keep them unchanged
|
|
||||||
if (is_string($value) && preg_match('#[+-]?\d++(e\d+)?\z#A', $value)) {
|
|
||||||
return $value;
|
|
||||||
} else {
|
|
||||||
return $value === NULL ? 'NULL' : (string) (int) ($value + 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'f': // float
|
|
||||||
// support for extreme numbers - keep them unchanged
|
|
||||||
if (is_string($value) && is_numeric($value) && strpos($value, 'x') === FALSE) {
|
|
||||||
return $value; // something like -9E-005 is accepted by SQL, HEX values are not
|
|
||||||
} else {
|
|
||||||
return $value === NULL ? 'NULL' : rtrim(rtrim(number_format($value + 0, 10, '.', ''), '0'), '.');
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'd': // date
|
|
||||||
case 't': // datetime
|
|
||||||
if ($value === NULL) {
|
|
||||||
return 'NULL';
|
|
||||||
} else {
|
|
||||||
if (is_numeric($value)) {
|
|
||||||
$value = (int) $value; // timestamp
|
|
||||||
|
|
||||||
} elseif (is_string($value)) {
|
|
||||||
$value = new DateTime($value);
|
|
||||||
}
|
}
|
||||||
return $this->driver->escape($value, $modifier);
|
// intentionally break omitted
|
||||||
}
|
|
||||||
|
|
||||||
case 'by':
|
case 'i': // signed int
|
||||||
case 'n': // identifier name
|
case 'u': // unsigned int, ignored
|
||||||
return $this->identifiers->$value;
|
// support for long numbers - keep them unchanged
|
||||||
|
if (is_string($value) && preg_match('#[+-]?\d++(e\d+)?\z#A', $value)) {
|
||||||
|
return $value;
|
||||||
|
} else {
|
||||||
|
return $value === NULL ? 'NULL' : (string) (int) ($value + 0);
|
||||||
|
}
|
||||||
|
|
||||||
case 'ex':
|
case 'f': // float
|
||||||
case 'sql': // preserve as dibi-SQL (TODO: leave only %ex)
|
// support for extreme numbers - keep them unchanged
|
||||||
$value = (string) $value;
|
if (is_string($value) && is_numeric($value) && strpos($value, 'x') === FALSE) {
|
||||||
// speed-up - is regexp required?
|
return $value; // something like -9E-005 is accepted by SQL, HEX values are not
|
||||||
$toSkip = strcspn($value, '`[\'":');
|
} else {
|
||||||
if (strlen($value) !== $toSkip) {
|
return $value === NULL ? 'NULL' : rtrim(rtrim(number_format($value + 0, 10, '.', ''), '0'), '.');
|
||||||
$value = substr($value, 0, $toSkip)
|
}
|
||||||
. preg_replace_callback(
|
|
||||||
'/(?=[`[\'":])(?:`(.+?)`|\[(.+?)\]|(\')((?:\'\'|[^\'])*)\'|(")((?:""|[^"])*)"|(\'|")|:(\S*?:)([a-zA-Z0-9._]?))/s',
|
|
||||||
array($this, 'cb'),
|
|
||||||
substr($value, $toSkip)
|
|
||||||
);
|
|
||||||
if (preg_last_error()) throw new DibiPcreException;
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
|
|
||||||
case 'SQL': // preserve as real SQL (TODO: rename to %sql)
|
case 'd': // date
|
||||||
return (string) $value;
|
case 't': // datetime
|
||||||
|
if ($value === NULL) {
|
||||||
|
return 'NULL';
|
||||||
|
} else {
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
$value = (int) $value; // timestamp
|
||||||
|
|
||||||
case 'like~': // LIKE string%
|
} elseif (is_string($value)) {
|
||||||
return $this->driver->escapeLike($value, 1);
|
$value = new DateTime($value);
|
||||||
|
}
|
||||||
|
return $this->driver->escape($value, $modifier);
|
||||||
|
}
|
||||||
|
|
||||||
case '~like': // LIKE %string
|
case 'by':
|
||||||
return $this->driver->escapeLike($value, -1);
|
case 'n': // identifier name
|
||||||
|
return $this->identifiers->$value;
|
||||||
|
|
||||||
case '~like~': // LIKE %string%
|
case 'ex':
|
||||||
return $this->driver->escapeLike($value, 0);
|
case 'sql': // preserve as dibi-SQL (TODO: leave only %ex)
|
||||||
|
$value = (string) $value;
|
||||||
|
// speed-up - is regexp required?
|
||||||
|
$toSkip = strcspn($value, '`[\'":');
|
||||||
|
if (strlen($value) !== $toSkip) {
|
||||||
|
$value = substr($value, 0, $toSkip)
|
||||||
|
. preg_replace_callback(
|
||||||
|
'/(?=[`[\'":])(?:`(.+?)`|\[(.+?)\]|(\')((?:\'\'|[^\'])*)\'|(")((?:""|[^"])*)"|(\'|")|:(\S*?:)([a-zA-Z0-9._]?))/s',
|
||||||
|
array($this, 'cb'),
|
||||||
|
substr($value, $toSkip)
|
||||||
|
);
|
||||||
|
if (preg_last_error()) {
|
||||||
|
throw new DibiPcreException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
|
||||||
case 'and':
|
case 'SQL': // preserve as real SQL (TODO: rename to %sql)
|
||||||
case 'or':
|
return (string) $value;
|
||||||
case 'a':
|
|
||||||
case 'l':
|
|
||||||
case 'v':
|
|
||||||
$this->hasError = TRUE;
|
|
||||||
return '**Unexpected type ' . gettype($value) . '**';
|
|
||||||
|
|
||||||
default:
|
case 'like~': // LIKE string%
|
||||||
$this->hasError = TRUE;
|
return $this->driver->escapeLike($value, 1);
|
||||||
return "**Unknown or invalid modifier %$modifier**";
|
|
||||||
|
case '~like': // LIKE %string
|
||||||
|
return $this->driver->escapeLike($value, -1);
|
||||||
|
|
||||||
|
case '~like~': // LIKE %string%
|
||||||
|
return $this->driver->escapeLike($value, 0);
|
||||||
|
|
||||||
|
case 'and':
|
||||||
|
case 'or':
|
||||||
|
case 'a':
|
||||||
|
case 'l':
|
||||||
|
case 'v':
|
||||||
|
$this->hasError = TRUE;
|
||||||
|
return '**Unexpected type ' . gettype($value) . '**';
|
||||||
|
|
||||||
|
default:
|
||||||
|
$this->hasError = TRUE;
|
||||||
|
return "**Unknown or invalid modifier %$modifier**";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +462,6 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PREG callback from translate() or formatValue().
|
* PREG callback from translate() or formatValue().
|
||||||
* @param array
|
* @param array
|
||||||
@@ -536,12 +540,16 @@ final class DibiTranslator extends DibiObject
|
|||||||
return '';
|
return '';
|
||||||
|
|
||||||
} elseif ($mod === 'lmt') { // apply limit
|
} elseif ($mod === 'lmt') { // apply limit
|
||||||
if ($this->args[$cursor] !== NULL) $this->limit = (int) $this->args[$cursor];
|
if ($this->args[$cursor] !== NULL) {
|
||||||
|
$this->limit = (int) $this->args[$cursor];
|
||||||
|
}
|
||||||
$cursor++;
|
$cursor++;
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
} elseif ($mod === 'ofs') { // apply offset
|
} elseif ($mod === 'ofs') { // apply offset
|
||||||
if ($this->args[$cursor] !== NULL) $this->offset = (int) $this->args[$cursor];
|
if ($this->args[$cursor] !== NULL) {
|
||||||
|
$this->offset = (int) $this->args[$cursor];
|
||||||
|
}
|
||||||
$cursor++;
|
$cursor++;
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
@@ -551,21 +559,23 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->comment) return '...';
|
if ($this->comment) {
|
||||||
|
return '...';
|
||||||
|
}
|
||||||
|
|
||||||
if ($matches[1]) // SQL identifiers: `ident`
|
if ($matches[1]) { // SQL identifiers: `ident`
|
||||||
return $this->identifiers->{$matches[1]};
|
return $this->identifiers->{$matches[1]};
|
||||||
|
|
||||||
if ($matches[2]) // SQL identifiers: [ident]
|
} elseif ($matches[2]) { // SQL identifiers: [ident]
|
||||||
return $this->identifiers->{$matches[2]};
|
return $this->identifiers->{$matches[2]};
|
||||||
|
|
||||||
if ($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);
|
||||||
|
|
||||||
if ($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);
|
||||||
|
|
||||||
if ($matches[7]) { // string quote
|
} elseif ($matches[7]) { // string quote
|
||||||
$this->hasError = TRUE;
|
$this->hasError = TRUE;
|
||||||
return '**Alone quote**';
|
return '**Alone quote**';
|
||||||
}
|
}
|
||||||
@@ -580,7 +590,6 @@ final class DibiTranslator extends DibiObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply substitutions to indentifier and delimites it.
|
* Apply substitutions to indentifier and delimites it.
|
||||||
* @param string indentifier
|
* @param string indentifier
|
||||||
@@ -592,7 +601,9 @@ final class DibiTranslator extends DibiObject
|
|||||||
$value = $this->connection->substitute($value);
|
$value = $this->connection->substitute($value);
|
||||||
$parts = explode('.', $value);
|
$parts = explode('.', $value);
|
||||||
foreach ($parts as & $v) {
|
foreach ($parts as & $v) {
|
||||||
if ($v !== '*') $v = $this->driver->escape($v, dibi::IDENTIFIER);
|
if ($v !== '*') {
|
||||||
|
$v = $this->driver->escape($v, dibi::IDENTIFIER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return implode('.', $parts);
|
return implode('.', $parts);
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an interface between a dataset and data-aware components.
|
* Provides an interface between a dataset and data-aware components.
|
||||||
* @package dibi
|
* @package dibi
|
||||||
@@ -22,7 +21,6 @@ interface IDataSource extends Countable, IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi driver interface.
|
* dibi driver interface.
|
||||||
* @package dibi
|
* @package dibi
|
||||||
@@ -36,7 +34,7 @@ interface IDibiDriver
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
function connect(array &$config);
|
function connect(array & $config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects from a database.
|
* Disconnects from a database.
|
||||||
@@ -120,19 +118,13 @@ interface IDibiDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects LIMIT/OFFSET to the SQL query.
|
* Injects LIMIT/OFFSET to the SQL query.
|
||||||
* @param string &$sql The SQL query that will be modified.
|
|
||||||
* @param int $limit
|
|
||||||
* @param int $offset
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function applyLimit(&$sql, $limit, $offset);
|
function applyLimit(& $sql, $limit, $offset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi result set driver interface.
|
* dibi result set driver interface.
|
||||||
* @package dibi
|
* @package dibi
|
||||||
@@ -193,9 +185,6 @@ interface IDibiResultDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dibi driver reflection.
|
* dibi driver reflection.
|
||||||
*
|
*
|
||||||
|
@@ -23,7 +23,6 @@ render(){$obLevel=ob_get_level();$panels=array();foreach($this->panels
|
|||||||
as$id=>$panel){try{$panels[]=array('id'=>preg_replace('#[^a-z0-9]+#i','-',$id),'tab'=>$tab=(string)$panel->getTab(),'panel'=>$tab?(string)$panel->getPanel():NULL);}catch(Exception$e){$panels[]=array('id'=>"error-$id",'tab'=>"Error: $id",'panel'=>nl2br(htmlSpecialChars((string)$e)));while(ob_get_level()>$obLevel){ob_end_clean();}}}?>
|
as$id=>$panel){try{$panels[]=array('id'=>preg_replace('#[^a-z0-9]+#i','-',$id),'tab'=>$tab=(string)$panel->getTab(),'panel'=>$tab?(string)$panel->getPanel():NULL);}catch(Exception$e){$panels[]=array('id'=>"error-$id",'tab'=>"Error: $id",'panel'=>nl2br(htmlSpecialChars((string)$e)));while(ob_get_level()>$obLevel){ob_end_clean();}}}?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Nette Debug Bar -->
|
<!-- Nette Debug Bar -->
|
||||||
|
|
||||||
<?php ob_start()?>
|
<?php ob_start()?>
|
||||||
@@ -130,7 +129,6 @@ htmlspecialchars('; caused by '.get_class($ex).' '.$ex->getMessage().($ex->getCo
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="netteBluescreen">
|
<div id="netteBluescreen">
|
||||||
<a id="netteBluescreenIcon" href="#" rel="next"><abbr>▼</abbr></a
|
<a id="netteBluescreenIcon" href="#" rel="next"><abbr>▼</abbr></a
|
||||||
@@ -146,7 +144,6 @@ urlencode($title.' '.preg_replace('#\'.*\'|".*"#Us','',$exception->getMessage())
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php $ex=$exception;$level=0;?>
|
<?php $ex=$exception;$level=0;?>
|
||||||
<?php do{?>
|
<?php do{?>
|
||||||
|
|
||||||
@@ -165,7 +162,6 @@ htmlspecialchars($ex->getMessage())?></b></p>
|
|||||||
<?php endif?>
|
<?php endif?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php foreach($panels
|
<?php foreach($panels
|
||||||
as$panel):?>
|
as$panel):?>
|
||||||
<?php $panel=call_user_func($panel,$ex);if(empty($panel['tab'])||empty($panel['panel']))continue;?>
|
<?php $panel=call_user_func($panel,$ex);if(empty($panel['tab'])||empty($panel['panel']))continue;?>
|
||||||
@@ -180,7 +176,6 @@ htmlSpecialChars($panel['tab'])?> <abbr>▼</abbr></a></h2>
|
|||||||
<?php endforeach?>
|
<?php endforeach?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php $stack=$ex->getTrace();$expanded=NULL?>
|
<?php $stack=$ex->getTrace();$expanded=NULL?>
|
||||||
<?php if(strpos($ex->getFile(),$expandPath)===0){foreach($stack
|
<?php if(strpos($ex->getFile(),$expandPath)===0){foreach($stack
|
||||||
as$key=>$row){if(isset($row['file'])&&strpos($row['file'],$expandPath)!==0){$expanded=$key;break;}}}?>
|
as$key=>$row){if(isset($row['file'])&&strpos($row['file'],$expandPath)!==0){$expanded=$key;break;}}}?>
|
||||||
@@ -196,7 +191,6 @@ self::highlightFile($ex->getFile(),$ex->getLine(),15,isset($ex->context)?$ex->co
|
|||||||
</div></div>
|
</div></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php if(isset($stack[0]['class'])&&$stack[0]['class']==='NDebugger'&&($stack[0]['function']==='_shutdownHandler'||$stack[0]['function']==='_errorHandler'))unset($stack[0])?>
|
<?php if(isset($stack[0]['class'])&&$stack[0]['class']==='NDebugger'&&($stack[0]['function']==='_shutdownHandler'||$stack[0]['function']==='_errorHandler'))unset($stack[0])?>
|
||||||
<?php if($stack):?>
|
<?php if($stack):?>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
@@ -251,7 +245,6 @@ self::highlightFile($row['file'],$row['line'])?></div>
|
|||||||
<?php endif?>
|
<?php endif?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php if(isset($ex->context)&&is_array($ex->context)):?>
|
<?php if(isset($ex->context)&&is_array($ex->context)):?>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">Variables <abbr>►</abbr></a></h2>
|
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">Variables <abbr>►</abbr></a></h2>
|
||||||
@@ -272,7 +265,6 @@ as$k=>$v){echo'<tr><th>$',htmlspecialchars($k),'</th><td>',NDebugHelpers::clicka
|
|||||||
<?php while(--$level)echo'</div></div>'?>
|
<?php while(--$level)echo'</div></div>'?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php $bottomPanels=array()?>
|
<?php $bottomPanels=array()?>
|
||||||
<?php foreach($panels
|
<?php foreach($panels
|
||||||
as$panel):?>
|
as$panel):?>
|
||||||
@@ -288,7 +280,6 @@ htmlSpecialChars($panel['tab'])?> <abbr>►</abbr></a></h2>
|
|||||||
<?php endforeach?>
|
<?php endforeach?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">Environment <abbr>►</abbr></a></h2>
|
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">Environment <abbr>►</abbr></a></h2>
|
||||||
|
|
||||||
@@ -336,7 +327,6 @@ as$k=>$v)echo'<tr><th>',htmlspecialchars($k),'</th><td>',NDebugHelpers::clickabl
|
|||||||
</div></div>
|
</div></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">HTTP request <abbr>►</abbr></a></h2>
|
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">HTTP request <abbr>►</abbr></a></h2>
|
||||||
|
|
||||||
@@ -371,7 +361,6 @@ foreach($GLOBALS[$name]as$k=>$v)echo'<tr><th>',htmlspecialchars($k),'</th><td>',
|
|||||||
</div></div>
|
</div></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">HTTP response <abbr>►</abbr></a></h2>
|
<h2><a href="#" rel="netteBsPnl<?php echo++$counter?>">HTTP response <abbr>►</abbr></a></h2>
|
||||||
|
|
||||||
@@ -388,7 +377,6 @@ htmlspecialchars($s),'<br>';?></pre>
|
|||||||
</div></div>
|
</div></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php foreach($bottomPanels
|
<?php foreach($bottomPanels
|
||||||
as$panel):?>
|
as$panel):?>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
@@ -401,7 +389,6 @@ htmlSpecialChars($panel['tab'])?> <abbr>▼</abbr></a></h2>
|
|||||||
<?php endforeach?>
|
<?php endforeach?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Report generated at <?php echo@date('Y/m/d H:i:s',NDebugger::$time)?></li>
|
<li>Report generated at <?php echo@date('Y/m/d H:i:s',NDebugger::$time)?></li>
|
||||||
<?php if(preg_match('#^https?://#',NDebugger::$source)):?>
|
<?php if(preg_match('#^https?://#',NDebugger::$source)):?>
|
||||||
|
@@ -18,7 +18,6 @@ project or top-level domain, and choose a name that stands on its own merits.
|
|||||||
If your stuff is good, it will not take long to establish a reputation for yourselves.
|
If your stuff is good, it will not take long to establish a reputation for yourselves.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
New BSD License
|
New BSD License
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GNU General Public License
|
GNU General Public License
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
@@ -23,8 +23,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to SQlite using DibiConnection object
|
// connects to SQlite using DibiConnection object
|
||||||
echo '<p>Connecting to Sqlite: ';
|
echo '<p>Connecting to Sqlite: ';
|
||||||
try {
|
try {
|
||||||
@@ -40,8 +38,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to MySQL using DSN
|
// connects to MySQL using DSN
|
||||||
echo '<p>Connecting to MySQL: ';
|
echo '<p>Connecting to MySQL: ';
|
||||||
try {
|
try {
|
||||||
@@ -54,8 +50,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to MySQLi using array
|
// connects to MySQLi using array
|
||||||
echo '<p>Connecting to MySQLi: ';
|
echo '<p>Connecting to MySQLi: ';
|
||||||
try {
|
try {
|
||||||
@@ -78,8 +72,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to ODBC
|
// connects to ODBC
|
||||||
echo '<p>Connecting to ODBC: ';
|
echo '<p>Connecting to ODBC: ';
|
||||||
try {
|
try {
|
||||||
@@ -97,8 +89,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to PostgreSql
|
// connects to PostgreSql
|
||||||
echo '<p>Connecting to PostgreSql: ';
|
echo '<p>Connecting to PostgreSql: ';
|
||||||
try {
|
try {
|
||||||
@@ -115,8 +105,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to PDO
|
// connects to PDO
|
||||||
echo '<p>Connecting to Sqlite via PDO: ';
|
echo '<p>Connecting to Sqlite via PDO: ';
|
||||||
try {
|
try {
|
||||||
@@ -132,7 +120,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to MS SQL
|
// connects to MS SQL
|
||||||
echo '<p>Connecting to MS SQL: ';
|
echo '<p>Connecting to MS SQL: ';
|
||||||
try {
|
try {
|
||||||
@@ -150,7 +137,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to MS SQL 2005
|
// connects to MS SQL 2005
|
||||||
echo '<p>Connecting to MS SQL 2005: ';
|
echo '<p>Connecting to MS SQL 2005: ';
|
||||||
try {
|
try {
|
||||||
@@ -169,7 +155,6 @@ try {
|
|||||||
echo "</p>\n";
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to Oracle
|
// connects to Oracle
|
||||||
echo '<p>Connecting to Oracle: ';
|
echo '<p>Connecting to Oracle: ';
|
||||||
try {
|
try {
|
||||||
|
@@ -14,7 +14,6 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// retrieve database reflection
|
// retrieve database reflection
|
||||||
$database = dibi::getDatabaseInfo();
|
$database = dibi::getDatabaseInfo();
|
||||||
|
|
||||||
@@ -26,7 +25,6 @@ foreach ($database->getTables() as $table) {
|
|||||||
echo "</ul>\n";
|
echo "</ul>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// table reflection
|
// table reflection
|
||||||
$table = $database->getTable('products');
|
$table = $database->getTable('products');
|
||||||
|
|
||||||
@@ -40,7 +38,6 @@ 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) {
|
||||||
|
@@ -14,7 +14,6 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$res = dibi::query('
|
$res = dibi::query('
|
||||||
SELECT * FROM products
|
SELECT * FROM products
|
||||||
INNER JOIN orders USING (product_id)
|
INNER JOIN orders USING (product_id)
|
||||||
|
@@ -31,7 +31,6 @@ dibi::connect(array(
|
|||||||
dibi::query('SELECT * FROM customers WHERE customer_id < ?', 38);
|
dibi::query('SELECT * FROM customers WHERE customer_id < ?', 38);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dibi::connect(array(
|
dibi::connect(array(
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'database' => 'data/sample.sdb',
|
'database' => 'data/sample.sdb',
|
||||||
|
@@ -32,8 +32,6 @@ dibi::test('
|
|||||||
// -> SELECT * FROM customers WHERE name LIKE 'K%'
|
// -> SELECT * FROM customers WHERE name LIKE 'K%'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if & else & (optional) end
|
// if & else & (optional) end
|
||||||
dibi::test("
|
dibi::test("
|
||||||
SELECT *
|
SELECT *
|
||||||
@@ -45,7 +43,6 @@ dibi::test("
|
|||||||
// -> SELECT * FROM people WHERE id > 0 AND bar=2
|
// -> SELECT * FROM people WHERE id > 0 AND bar=2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// nested condition
|
// nested condition
|
||||||
dibi::test('
|
dibi::test('
|
||||||
SELECT *
|
SELECT *
|
||||||
@@ -58,7 +55,6 @@ dibi::test('
|
|||||||
// -> SELECT * FROM customers WHERE LIMIT 10
|
// -> SELECT * FROM customers WHERE LIMIT 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// IF()
|
// IF()
|
||||||
dibi::test('UPDATE products SET', array(
|
dibi::test('UPDATE products SET', array(
|
||||||
'price' => array('IF(price_fixed, price, ?)', 123),
|
'price' => array('IF(price_fixed, price, ?)', 123),
|
||||||
|
@@ -29,7 +29,6 @@ dibi::test('
|
|||||||
// -> SELECT COUNT(*) as [count] FROM [comments] WHERE [ip] LIKE '192.168.%' AND [date] > 876693600
|
// -> SELECT COUNT(*) as [count] FROM [comments] WHERE [ip] LIKE '192.168.%' AND [date] > 876693600
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// dibi detects INSERT or REPLACE command
|
// dibi detects INSERT or REPLACE command
|
||||||
dibi::test('
|
dibi::test('
|
||||||
REPLACE INTO products', array(
|
REPLACE INTO products', array(
|
||||||
@@ -40,7 +39,6 @@ dibi::test('
|
|||||||
// -> REPLACE INTO products ([title], [price], [active]) VALUES ('Super product', 318, 1)
|
// -> REPLACE INTO products ([title], [price], [active]) VALUES ('Super product', 318, 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// multiple INSERT command
|
// multiple INSERT command
|
||||||
$array = array(
|
$array = array(
|
||||||
'title' => 'Super Product',
|
'title' => 'Super Product',
|
||||||
@@ -52,7 +50,6 @@ 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(
|
||||||
@@ -63,7 +60,6 @@ dibi::test("
|
|||||||
// -> 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("
|
||||||
@@ -74,7 +70,6 @@ dibi::test("
|
|||||||
// -> SELECT * FROM people WHERE id IN ( 1, 2, 3 )
|
// -> SELECT * FROM people WHERE id IN ( 1, 2, 3 )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// modifier %by for ORDER BY
|
// modifier %by for ORDER BY
|
||||||
$order = array(
|
$order = array(
|
||||||
'field1' => 'asc',
|
'field1' => 'asc',
|
||||||
@@ -88,7 +83,6 @@ dibi::test("
|
|||||||
// -> SELECT * FROM people ORDER BY [field1] ASC, [field2] DESC
|
// -> SELECT * FROM people ORDER BY [field1] ASC, [field2] DESC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// indentifiers and strings syntax mix
|
// indentifiers and strings syntax mix
|
||||||
dibi::test('UPDATE [table] SET `item` = "5 1/4"" diskette"');
|
dibi::test('UPDATE [table] SET `item` = "5 1/4"" diskette"');
|
||||||
// -> UPDATE [table] SET [item] = '5 1/4" diskette'
|
// -> UPDATE [table] SET [item] = '5 1/4" diskette'
|
||||||
|
@@ -33,7 +33,6 @@ dump( $res->fetch() );
|
|||||||
// added => "2007-03-11 17:20:03" (19)
|
// added => "2007-03-11 17:20:03" (19)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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]');
|
||||||
|
|
||||||
|
@@ -10,7 +10,6 @@ require dirname(__FILE__) . '/../dibi/dibi.php';
|
|||||||
date_default_timezone_set('Europe/Prague');
|
date_default_timezone_set('Europe/Prague');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CHANGE TO REAL PARAMETERS!
|
// CHANGE TO REAL PARAMETERS!
|
||||||
dibi::connect(array(
|
dibi::connect(array(
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
@@ -20,7 +19,6 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// generate and dump SQL
|
// generate and dump SQL
|
||||||
dibi::test("
|
dibi::test("
|
||||||
INSERT INTO [mytable]", array(
|
INSERT INTO [mytable]", array(
|
||||||
|
@@ -15,7 +15,6 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// using the "prototype" to add custom method to class DibiResult
|
// using the "prototype" to add custom method to class DibiResult
|
||||||
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
|
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
|
||||||
{
|
{
|
||||||
|
@@ -35,7 +35,6 @@ dibi::select('product_id')->as('id')
|
|||||||
// USING (product_id) INNER JOIN customers USING (customer_id) ORDER BY [title]
|
// USING (product_id) INNER JOIN customers USING (customer_id) ORDER BY [title]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// SELECT ...
|
// SELECT ...
|
||||||
echo dibi::select('title')->as('id')
|
echo dibi::select('title')->as('id')
|
||||||
->from('products')
|
->from('products')
|
||||||
@@ -43,7 +42,6 @@ echo dibi::select('title')->as('id')
|
|||||||
// -> Chair (as result of query: SELECT [title] AS [id] FROM [products])
|
// -> Chair (as result of query: SELECT [title] AS [id] FROM [products])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// INSERT ...
|
// INSERT ...
|
||||||
dibi::insert('products', $record)
|
dibi::insert('products', $record)
|
||||||
->setFlag('IGNORE')
|
->setFlag('IGNORE')
|
||||||
@@ -51,7 +49,6 @@ dibi::insert('products', $record)
|
|||||||
// -> INSERT IGNORE INTO [products] ([title], [price], [active]) VALUES ('Super product', 318, 1)
|
// -> INSERT IGNORE INTO [products] ([title], [price], [active]) VALUES ('Super product', 318, 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// UPDATE ...
|
// UPDATE ...
|
||||||
dibi::update('products', $record)
|
dibi::update('products', $record)
|
||||||
->where('product_id = ?', $id)
|
->where('product_id = ?', $id)
|
||||||
@@ -59,7 +56,6 @@ dibi::update('products', $record)
|
|||||||
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
|
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DELETE ...
|
// DELETE ...
|
||||||
dibi::delete('products')
|
dibi::delete('products')
|
||||||
->where('product_id = ?', $id)
|
->where('product_id = ?', $id)
|
||||||
@@ -67,7 +63,6 @@ dibi::delete('products')
|
|||||||
// -> DELETE FROM [products] WHERE product_id = 10
|
// -> DELETE FROM [products] WHERE product_id = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// custom commands
|
// custom commands
|
||||||
dibi::command()
|
dibi::command()
|
||||||
->update('products')
|
->update('products')
|
||||||
@@ -77,7 +72,6 @@ dibi::command()
|
|||||||
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
|
// -> UPDATE [products] SET [title]='Super product', [price]=318, [active]=1 WHERE product_id = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dibi::command()
|
dibi::command()
|
||||||
->truncate('products')
|
->truncate('products')
|
||||||
->test();
|
->test();
|
||||||
|
@@ -19,13 +19,11 @@ dibi::test('SELECT * FROM [products]');
|
|||||||
// -> SELECT * FROM [products]
|
// -> SELECT * FROM [products]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// with limit = 2
|
// with limit = 2
|
||||||
dibi::test('SELECT * FROM [products] %lmt', 2);
|
dibi::test('SELECT * FROM [products] %lmt', 2);
|
||||||
// -> SELECT * FROM [products] LIMIT 2
|
// -> SELECT * FROM [products] LIMIT 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// with limit = 2, offset = 1
|
// with limit = 2, offset = 1
|
||||||
dibi::test('SELECT * FROM [products] %lmt %ofs', 2, 1);
|
dibi::test('SELECT * FROM [products] %lmt %ofs', 2, 1);
|
||||||
// -> SELECT * FROM [products] LIMIT 2 OFFSET 1
|
// -> SELECT * FROM [products] LIMIT 2 OFFSET 1
|
||||||
|
@@ -21,7 +21,6 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] = ?', 1);
|
$res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] = ?', 1);
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<?php ob_start(1) // needed by FirePHP ?>
|
<?php ob_start() // needed by FirePHP ?>
|
||||||
|
|
||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
|
@@ -14,8 +14,6 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create new substitution :blog: ==> wp_
|
// create new substitution :blog: ==> wp_
|
||||||
dibi::getSubstitutes()->blog = 'wp_';
|
dibi::getSubstitutes()->blog = 'wp_';
|
||||||
|
|
||||||
@@ -23,9 +21,6 @@ dibi::test("SELECT * FROM [:blog:items]");
|
|||||||
// -> SELECT * FROM [wp_items]
|
// -> SELECT * FROM [wp_items]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create new substitution :: (empty) ==> my_
|
// create new substitution :: (empty) ==> my_
|
||||||
dibi::getSubstitutes()->{''} = 'my_';
|
dibi::getSubstitutes()->{''} = 'my_';
|
||||||
|
|
||||||
@@ -33,9 +28,6 @@ dibi::test("UPDATE ::table SET [text]='Hello World'");
|
|||||||
// -> UPDATE my_table SET [text]='Hello World'
|
// -> UPDATE my_table SET [text]='Hello World'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create substitutions using fallback callback
|
// create substitutions using fallback callback
|
||||||
function substFallBack($expr)
|
function substFallBack($expr)
|
||||||
{
|
{
|
||||||
|
@@ -13,7 +13,6 @@ use Dibi in commercial projects as long as the copyright header
|
|||||||
remains intact.
|
remains intact.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
New BSD License
|
New BSD License
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ any theory of liability, whether in contract, strict liability, or tort
|
|||||||
software, even if advised of the possibility of such damage.
|
software, even if advised of the possibility of such damage.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GNU General Public License
|
GNU General Public License
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require dirname(__FILE__) . '/bootstrap.php';
|
require dirname(__FILE__) . '/bootstrap.php';
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +24,6 @@ Assert::same( 'SELECT * FROM [table] WHERE x=1', (string) $fluent );
|
|||||||
Assert::same( 'SELECT * FROM [table] WHERE x=1 AND y=1 FOO', (string) $dolly );
|
Assert::same( 'SELECT * FROM [table] WHERE x=1 AND y=1 FOO', (string) $dolly );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$fluent = dibi::select('id')->from('table')->where('id = %i',1);
|
$fluent = dibi::select('id')->from('table')->where('id = %i',1);
|
||||||
$dolly = clone $fluent;
|
$dolly = clone $fluent;
|
||||||
$dolly->where('cd = %i',5);
|
$dolly->where('cd = %i',5);
|
||||||
@@ -34,7 +32,6 @@ 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 );
|
Assert::same( 'SELECT [id] FROM [table] WHERE id = 1 AND cd = 5', (string) $dolly );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$fluent = dibi::select("*")->from("table");
|
$fluent = dibi::select("*")->from("table");
|
||||||
$dolly = clone $fluent;
|
$dolly = clone $fluent;
|
||||||
$dolly->removeClause("select")->select("count(*)");
|
$dolly->removeClause("select")->select("count(*)");
|
||||||
|
Reference in New Issue
Block a user