move shimmie-specific sqlite things out of adodb and into shimmie's database engine
This commit is contained in:
parent
2d46a5c269
commit
4e551cf9c5
@ -90,15 +90,32 @@ class PostgreSQL extends DBEngine {
|
||||
return "CREATE TABLE $name ($data)";
|
||||
}
|
||||
}
|
||||
|
||||
// shimmie functions for export to sqlite
|
||||
function _unix_timestamp($date) { return strtotime($date); }
|
||||
function _now() { return date("Y-m-d h:i:s"); }
|
||||
function _floor($a) { return floor($a); }
|
||||
function _log1($a) { return log($a); }
|
||||
function _log2($a, $b) { return log($a, $b); }
|
||||
function _isnull($a) { return is_null($a); }
|
||||
function _md5($a) { return md5($a); }
|
||||
function _concat($a, $b) { return $a . $b; }
|
||||
function _lower($a) { return strtolower($a); }
|
||||
|
||||
class SQLite extends DBEngine {
|
||||
var $name = "sqlite";
|
||||
|
||||
public function init($db) {
|
||||
// TODO: add functions:
|
||||
// now()
|
||||
// unix_timestamp()
|
||||
// lower()
|
||||
// log(base, number)
|
||||
ini_set('sqlite.assoc_case', 0);
|
||||
@sqlite_create_function($db->_connectionID, 'UNIX_TIMESTAMP', '_unix_timestamp', 1);
|
||||
@sqlite_create_function($db->_connectionID, 'now', '_now', 0);
|
||||
@sqlite_create_function($db->_connectionID, 'floor', '_floor', 1);
|
||||
@sqlite_create_function($db->_connectionID, 'log', '_log1', 1);
|
||||
@sqlite_create_function($db->_connectionID, 'log', '_log2', 2);
|
||||
@sqlite_create_function($db->_connectionID, 'isnull', '_isnull', 1);
|
||||
@sqlite_create_function($db->_connectionID, 'md5', '_md5', 1);
|
||||
@sqlite_create_function($db->_connectionID, 'concat', '_concat', 2);
|
||||
@sqlite_create_function($db->_connectionID, 'lower', '_lower', 1);
|
||||
}
|
||||
|
||||
public function create_table_sql($name, $data) {
|
||||
|
@ -152,15 +152,6 @@ class ADODB_sqlite extends ADOConnection {
|
||||
{
|
||||
@sqlite_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1);
|
||||
@sqlite_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2);
|
||||
|
||||
// XXX: shimmie customisation, as suggested by naikoto on the forums
|
||||
@sqlite_create_function($this->_connectionID, 'UNIX_TIMESTAMP', 'UNIX_TIMESTAMP', 1);
|
||||
@sqlite_create_function($this->_connectionID, 'now', 'now', 0);
|
||||
@sqlite_create_function($this->_connectionID, 'floor', 'mfloor', 1);
|
||||
@sqlite_create_function($this->_connectionID, 'log', 'mlog', 1);
|
||||
@sqlite_create_function($this->_connectionID, 'isnull', 'fisnull', 1);
|
||||
@sqlite_create_function($this->_connectionID, 'md5', 'fmd5', 1);
|
||||
@sqlite_create_function($this->_connectionID, 'concat', 'fconcat', 2);
|
||||
}
|
||||
|
||||
|
||||
@ -402,16 +393,5 @@ class ADORecordset_sqlite extends ADORecordSet {
|
||||
function _close()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// shimmie functions
|
||||
ini_set ( 'sqlite.assoc_case' , 0 );
|
||||
function UNIX_TIMESTAMP($date) { return strtotime($date); }
|
||||
function now() { return date("Y-m-d h:i:s"); }
|
||||
function mfloor($a) { return floor($a); }
|
||||
function mlog($a) { return log($a); }
|
||||
function fisnull($a) { return is_null($a); }
|
||||
function fmd5($a) { return md5($a); }
|
||||
function fconcat($a, $b) { return $a . $b; }
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user