]> source.dussan.org Git - nextcloud-server.git/commitdiff
gain compatibility with sqlite3
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Tue, 16 Aug 2011 21:49:53 +0000 (23:49 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Tue, 16 Aug 2011 21:49:53 +0000 (23:49 +0200)
apps/bookmarks/ajax/addBookmark.php
apps/bookmarks/ajax/updateList.php

index b0d1a7308978df89c4353ef7da1f12130f4a9a40..d3d23aad2678a6a90b02e4a4fd4310407f8d3832 100644 (file)
@@ -35,12 +35,21 @@ if( !OC_User::isLoggedIn()){
        exit();
 }
 
+$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
+if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
+       $_ut = "strftime('%s','now')";
+} else {
+       $_ut = "UNIX_TIMESTAMP()";
+}
+
+//FIXME: Detect when user adds a known URL
 $query = OC_DB::prepare("
-       INSERT IGNORE INTO *PREFIX*bookmarks
+       INSERT INTO *PREFIX*bookmarks
        (url, title, description, user_id, public, added, lastmodified)
-       VALUES (?, ?, ?, ?, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())
+       VALUES (?, ?, ?, ?, 0, $_ut, $_ut)
        ");
        
+       
 $params=array(
        urldecode($_GET["url"]),
        urldecode($_GET["title"]),
@@ -50,6 +59,7 @@ $params=array(
 $query->execute($params);
 $b_id = OC_DB::insertid();
 
+
 if($b_id !== false) {
        $query = OC_DB::prepare("
                INSERT INTO *PREFIX*bookmarks_tags
index d7cf05b7a60ea2ae0d259361e303ce89bebad20a..1217a64c6e1a6996e3e8e23b99dfd9ee4dc7554b 100644 (file)
@@ -49,9 +49,16 @@ if($filterTag){
 $offset = isset($_GET["page"]) ? intval($_GET["page"]) * 10 : 0;
 $params[] = $offset;
 
+$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
+if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
+       $_gc_separator = ", ' '";
+} else {
+       $_gc_separator = "SEPARATOR ' '";
+}
+
 //FIXME: bookmarks without tags are not being retrieved
 $query = OC_DB::prepare("
-       SELECT url, title, description, GROUP_CONCAT( tag SEPARATOR ' ' ) AS tags
+       SELECT url, title, description, GROUP_CONCAT( tag $_gc_separator ) AS tags
        FROM *PREFIX*bookmarks, *PREFIX*bookmarks_tags 
        WHERE *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id
                AND *PREFIX*bookmarks.user_id = ?