mirror of
https://github.com/dg/dibi.git
synced 2025-08-29 16:59:49 +02:00
- added DibiFluent
- bugfix in dibi::dump()
This commit is contained in:
@@ -52,6 +52,7 @@ require_once dirname(__FILE__) . '/libs/DibiTranslator.php';
|
||||
require_once dirname(__FILE__) . '/libs/DibiVariable.php';
|
||||
require_once dirname(__FILE__) . '/libs/DibiTable.php';
|
||||
require_once dirname(__FILE__) . '/libs/DibiDataSource.php';
|
||||
require_once dirname(__FILE__) . '/libs/DibiFluent.php';
|
||||
|
||||
|
||||
|
||||
@@ -424,11 +425,76 @@ class dibi
|
||||
*/
|
||||
protected static function __callStatic($name, $args)
|
||||
{
|
||||
//if ($name = 'select', 'update', ...') {
|
||||
// return self::command()->$name($args);
|
||||
//}
|
||||
return call_user_func_array(array(self::getConnection(), $name), $args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* fluent SQL builders ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function command()
|
||||
{
|
||||
return new DibiFluent(self::getConnection());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string column name
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function select($args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
return self::command()->__call('select', $args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string table
|
||||
* @param array
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function update($table, array $args)
|
||||
{
|
||||
return self::command()->update('%n', $table)->set($args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string table
|
||||
* @param array
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function insert($table, array $args)
|
||||
{
|
||||
return self::command()->insert()
|
||||
->into('%n', $table, '(%n)', array_keys($args))->values('%l', array_values($args));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string table
|
||||
* @return DibiFluent
|
||||
*/
|
||||
public static function delete($table)
|
||||
{
|
||||
return self::command()->delete()->from('%n', $table);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* data types ****************d*g**/
|
||||
|
||||
|
||||
@@ -593,8 +659,8 @@ class dibi
|
||||
} else {
|
||||
if ($sql === NULL) $sql = self::$sql;
|
||||
|
||||
static $keywords1 = 'SELECT|UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|DELETE|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE';
|
||||
static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|TRUE|FALSE';
|
||||
static $keywords1 = 'SELECT|UPDATE|INSERT(?:\s+INTO)|REPLACE(?:\s+INTO)|DELETE|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN';
|
||||
|
||||
// insert new lines
|
||||
$sql = ' ' . $sql;
|
||||
@@ -647,7 +713,8 @@ class dibi
|
||||
{
|
||||
return array(
|
||||
'dibi version: ' . dibi::VERSION,
|
||||
'Number or queries: ' . dibi::$numOfQueries . (dibi::$totalTime === NULL ? '' : ' (elapsed time: ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms)'),
|
||||
'Number or queries: ' . dibi::$numOfQueries
|
||||
. (dibi::$totalTime === NULL ? '' : ' (elapsed time: ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms)'),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user