From e8ffd5c04249f84770e618eeb57f39c2e93afe35 Mon Sep 17 00:00:00 2001 From: jfd Date: Sat, 25 Aug 2012 02:27:43 +0200 Subject: [PATCH] use limit parameter instead of LIMIT SQL for vcard --- apps/contacts/lib/vcard.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 042ad1e990..91a5b806b1 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -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);