1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-01-19 15:52:10 +01:00

Change manual limit and offset with OC DB function

This commit is contained in:
Brice Maron 2012-10-11 20:27:25 +00:00
parent 84cb325822
commit f017cfdbf8

View File

@ -42,9 +42,9 @@ class OC_Bookmarks_Bookmarks{
$sql = 'SELECT tag, count(*) as nbr from *PREFIX*bookmarks_tags t '. $sql = 'SELECT tag, count(*) as nbr from *PREFIX*bookmarks_tags t '.
' WHERE EXISTS( SELECT 1 from *PREFIX*bookmarks bm where t.bookmark_id = bm.id and user_id = ?) '. ' WHERE EXISTS( SELECT 1 from *PREFIX*bookmarks bm where t.bookmark_id = bm.id and user_id = ?) '.
$not_in. $not_in.
' group by tag Order by nbr DESC LIMIT '.$limit.' OFFSET '.$offset; ' group by tag Order by nbr DESC ';
$query = OCP\DB::prepare($sql); $query = OCP\DB::prepare($sql, $limit, $offset);
$tags = $query->execute($params)->fetchAll(); $tags = $query->execute($params)->fetchAll();
return $tags; return $tags;
} }
@ -86,12 +86,12 @@ class OC_Bookmarks_Bookmarks{
} }
} }
$sql .= " ORDER BY ".$sqlSortColumn." DESC "; $sql .= " ORDER BY ".$sqlSortColumn." DESC ";
if($limit != -1 && $limit !== false) { if($limit == -1 || $limit === false) {
$sql .= " LIMIT $limit "; $limit = null;
$sql .= " OFFSET $offset"; $offset = null;
} }
$query = OCP\DB::prepare($sql); $query = OCP\DB::prepare($sql, $limit, $offset);
$results = $query->execute($params)->fetchAll(); $results = $query->execute($params)->fetchAll();
$bookmarks = array(); $bookmarks = array();
foreach($results as $result){ foreach($results as $result){