]> source.dussan.org Git - nextcloud-server.git/commitdiff
use limit parameter instead of LIMIT SQL for vcard
authorjfd <jfd@lance>
Sat, 25 Aug 2012 00:27:43 +0000 (02:27 +0200)
committerjfd <jfd@lance>
Sat, 25 Aug 2012 00:27:43 +0000 (02:27 +0200)
apps/contacts/lib/vcard.php

index 042ad1e990b2dfd94ab26be3a8c9ba1c92d8f7c5..91a5b806b10a8813732c6f8b088ff8c749ae66f2 100644 (file)
@@ -48,31 +48,23 @@ class OC_Contacts_VCard {
         * ['carddata']
         */
        public static function all($id, $start=null, $num=null){
-               //FIXME jfd: use limit & offset as OC_DB::prepare parameters for oracle support
-               $limitsql = '';
-               if(!is_null($num)) {
-                       $limitsql = ' LIMIT '.$num;
-               }
-               if(!is_null($start) && !is_null($num)) {
-                       $limitsql .= ' OFFSET '.$start.' ';
-               }
                $result = null;
                if(is_array($id) && count($id)) {
                        $id_sql = join(',', array_fill(0, count($id), '?'));
-                       $prep = 'SELECT * FROM `*PREFIX*contacts_cards` WHERE `addressbookid` IN ('.$id_sql.') ORDER BY `fullname`'.$limitsql;
+                       $sql = 'SELECT * FROM `*PREFIX*contacts_cards` WHERE `addressbookid` IN ('.$id_sql.') ORDER BY `fullname`';
                        try {
-                               $stmt = OCP\DB::prepare( $prep );
+                               $stmt = OCP\DB::prepare( $sql, $num, $start );
                                $result = $stmt->execute($id);
                        } catch(Exception $e) {
                                OCP\Util::writeLog('contacts', __METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
                                OCP\Util::writeLog('contacts', __METHOD__.', ids: '.join(',', $id), OCP\Util::DEBUG);
-                               OCP\Util::writeLog('contacts', __METHOD__.'SQL:'.$prep, OCP\Util::DEBUG);
+                               OCP\Util::writeLog('contacts', __METHOD__.'SQL:'.$sql, OCP\Util::DEBUG);
                                return false;
                        }
                } elseif(is_int($id) || is_string($id)) {
                        try {
-                               $sql = 'SELECT * FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? ORDER BY `fullname`'.$limitsql;
-                               $stmt = OCP\DB::prepare( $sql );
+                               $sql = 'SELECT * FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? ORDER BY `fullname`';
+                               $stmt = OCP\DB::prepare( $sql, $num, $start );
                                $result = $stmt->execute(array($id));
                        } catch(Exception $e) {
                                OCP\Util::writeLog('contacts', __METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);