summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-06-13 04:06:43 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-06-13 04:06:43 +0200
commit1ea43dd7f9928ac6e74f36822ccb4deeeb804db3 (patch)
tree5b1283e264769460899befb43c71fe7c9fd20671 /lib
parent600219c8c0bec3f3998e0170dd3363ac6cc7824e (diff)
downloadnextcloud-server-1ea43dd7f9928ac6e74f36822ccb4deeeb804db3.tar.gz
nextcloud-server-1ea43dd7f9928ac6e74f36822ccb4deeeb804db3.zip
make OC_DB work with the sqlite3 driver
Diffstat (limited to 'lib')
-rw-r--r--lib/database.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/database.php b/lib/database.php
index 0f0950d05ad..8d7c76756c1 100644
--- a/lib/database.php
+++ b/lib/database.php
@@ -60,10 +60,10 @@ class OC_DB {
'quote_identifier' => true );
// Add the dsn according to the database type
- if( $CONFIG_DBTYPE == 'sqlite' ){
+ if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
// sqlite
$dsn = array(
- 'phptype' => 'sqlite',
+ 'phptype' => $CONFIG_DBTYPE,
'database' => "$datadir/$CONFIG_DBNAME.db",
'mode' => '0644' );
}
@@ -100,6 +100,9 @@ class OC_DB {
// We always, really always want associative arrays
self::$DBConnection->setFetchMode(MDB2_FETCHMODE_ASSOC);
+
+ //we need to function module for query pre-procesing
+ self::$DBConnection->loadModule('Function');
}
// we are done. great!
@@ -297,15 +300,14 @@ class OC_DB {
* and replaces the ` woth ' or " according to the database driver.
*/
private static function processQuery( $query ){
+ self::connect();
// We need Database type and table prefix
$CONFIG_DBTYPE = OC_CONFIG::getValue( "dbtype", "sqlite" );
$CONFIG_DBTABLEPREFIX = OC_CONFIG::getValue( "dbtableprefix", "oc_" );
// differences is getting the current timestamp
- if( $CONFIG_DBTYPE == 'sqlite' ){
- $query = str_replace( 'NOW()', "strftime('%s', 'now')", $query );
- $query = str_replace( 'now()', "strftime('%s', 'now')", $query );
- }
+ $query = str_replace( 'NOW()', self::$DBConnection->now(), $query );
+ $query = str_replace( 'now()', self::$DBConnection->now(), $query );
// differences in escaping of table names (` for mysql)
// Problem: what if there is a ` in the value we want to insert?