summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2012-07-30 22:42:43 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2012-08-01 14:59:08 +0200
commite13f381189788c74fe08a3f3336d961977ff9dc4 (patch)
tree19b81673f6804e718534e4c6a286c94e0a2743b8 /apps
parent795e78809f55be762fb07d9a179bbdffa7aefbd9 (diff)
downloadnextcloud-server-e13f381189788c74fe08a3f3336d961977ff9dc4.tar.gz
nextcloud-server-e13f381189788c74fe08a3f3336d961977ff9dc4.zip
add limit support to OC_DB & OCP/DB
Diffstat (limited to 'apps')
-rw-r--r--apps/bookmarks/lib/bookmarks.php9
-rw-r--r--apps/files_sharing/lib_share.php14
-rw-r--r--apps/remoteStorage/lib_remoteStorage.php6
3 files changed, 14 insertions, 15 deletions
diff --git a/apps/bookmarks/lib/bookmarks.php b/apps/bookmarks/lib/bookmarks.php
index 4b9e3d6438a..d569bf528a1 100644
--- a/apps/bookmarks/lib/bookmarks.php
+++ b/apps/bookmarks/lib/bookmarks.php
@@ -78,9 +78,8 @@ class OC_Bookmarks_Bookmarks{
`*PREFIX*bookmarks`.`user_id` = ?
GROUP BY `id`, `url`, `title`
'.$sqlFilterTag.'
- ORDER BY `*PREFIX*bookmarks`.`'.$sqlSortColumn.'` DESC
- LIMIT 10
- OFFSET '. $offset);
+ ORDER BY `*PREFIX*bookmarks`.`'.$sqlSortColumn.'` DESC',
+ 10,$offset);
} else {
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' )
$concatFunction = '(url || title || ';
@@ -106,8 +105,8 @@ class OC_Bookmarks_Bookmarks{
AND `*PREFIX*bookmarks`.`user_id` = ?
GROUP BY `url`
'.$sqlFilterTag.'
- ORDER BY `*PREFIX*bookmarks`.`'.$sqlSortColumn.'` DESC
- LIMIT '.$offset.', 10');
+ ORDER BY `*PREFIX*bookmarks`.`'.$sqlSortColumn.'` DESC',
+ 10, $offset);
}
$bookmarks = $query->execute($params)->fetchAll();
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 05a80b79161..fe312ad9ed7 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -92,7 +92,7 @@ class OC_Share {
// Check if the target already exists for the user, if it does append a number to the name
$sharedFolder = '/'.$uid.'/files/Shared';
$target = $sharedFolder."/".basename($source);
- $checkTarget = OCP\DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups($uid, false).' LIMIT 1');
+ $checkTarget = OCP\DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups($uid, false),1);
$result = $checkTarget->execute(array($target))->fetchAll();
if (count($result) > 0) {
if ($pos = strrpos($target, ".")) {
@@ -222,7 +222,7 @@ class OC_Share {
*/
public static function getItem($target) {
$target = self::cleanPath($target);
- $query = OCP\DB::prepare('SELECT `uid_owner`, `source`, `permissions` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` = ? LIMIT 1');
+ $query = OCP\DB::prepare('SELECT `uid_owner`, `source`, `permissions` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` = ?',1);
return $query->execute(array($target, OCP\USER::getUser()))->fetchAll();
}
@@ -279,7 +279,7 @@ class OC_Share {
*/
public static function getParentFolders($target) {
$target = self::cleanPath($target);
- $query = OCP\DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups().' LIMIT 1');
+ $query = OCP\DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups(),1);
// Prevent searching for user directory e.g. '/MTGap/files'
$userDirectory = substr($target, 0, strpos($target, "files") + 5);
$target = dirname($target);
@@ -307,7 +307,7 @@ class OC_Share {
*/
public static function getSource($target) {
$target = self::cleanPath($target);
- $query = OCP\DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups().' LIMIT 1');
+ $query = OCP\DB::prepare('SELECT `source` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups(),1);
$result = $query->execute(array($target))->fetchAll();
if (count($result) > 0) {
return $result[0]['source'];
@@ -323,7 +323,7 @@ class OC_Share {
public static function getTarget($source) {
$source = self::cleanPath($source);
- $query = OCP\DB::prepare('SELECT `target` FROM `*PREFIX*sharing` WHERE `source` = ? AND `uid_owner` = ? LIMIT 1');
+ $query = OCP\DB::prepare('SELECT `target` FROM `*PREFIX*sharing` WHERE `source` = ? AND `uid_owner` = ',1);
$result = $query->execute(array($source, OCP\USER::getUser()))->fetchAll();
if (count($result) > 0) {
return $result[0]['target'];
@@ -340,7 +340,7 @@ class OC_Share {
*/
public static function getPermissions($target) {
$target = self::cleanPath($target);
- $query = OCP\DB::prepare('SELECT `permissions` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups().' LIMIT 1');
+ $query = OCP\DB::prepare('SELECT `permissions` FROM `*PREFIX*sharing` WHERE `target` = ? AND `uid_shared_with` '.self::getUsersAndGroups(),1);
$result = $query->execute(array($target))->fetchAll();
if (count($result) > 0) {
return $result[0]['permissions'];
@@ -372,7 +372,7 @@ class OC_Share {
* @return The token of the public link, a sha1 hash
*/
public static function getTokenFromSource($source) {
- $query = OCP\DB::prepare('SELECT `target` FROM `*PREFIX*sharing` WHERE `source` = ? AND `uid_shared_with` = ? AND `uid_owner` = ? LIMIT 1');
+ $query = OCP\DB::prepare('SELECT `target` FROM `*PREFIX*sharing` WHERE `source` = ? AND `uid_shared_with` = ? AND `uid_owner` = ?',1);
$result = $query->execute(array($source, self::PUBLICLINK, OCP\USER::getUser()))->fetchAll();
if (count($result) > 0) {
return $result[0]['target'];
diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php
index 7c7e455d823..b6934e87d67 100644
--- a/apps/remoteStorage/lib_remoteStorage.php
+++ b/apps/remoteStorage/lib_remoteStorage.php
@@ -2,7 +2,7 @@
class OC_remoteStorage {
public static function getValidTokens($ownCloudUser, $category) {
- $query=OCP\DB::prepare("SELECT `token`,`appUrl`,`category` FROM `*PREFIX*authtoken` WHERE `user`=? LIMIT 100");
+ $query=OCP\DB::prepare("SELECT `token`,`appUrl`,`category` FROM `*PREFIX*authtoken` WHERE `user`=?",100);
$result=$query->execute(array($ownCloudUser));
$ret = array();
while($row=$result->fetchRow()){
@@ -15,7 +15,7 @@ class OC_remoteStorage {
public static function getTokenFor($appUrl, $categories) {
$user=OCP\USER::getUser();
- $query=OCP\DB::prepare("SELECT `token` FROM `*PREFIX*authtoken` WHERE `user`=? AND `appUrl`=? AND `category`=? LIMIT 1");
+ $query=OCP\DB::prepare("SELECT `token` FROM `*PREFIX*authtoken` WHERE `user`=? AND `appUrl`=? AND `category`=?",1);
$result=$query->execute(array($user, $appUrl, $categories));
$ret = array();
if($row=$result->fetchRow()) {
@@ -27,7 +27,7 @@ class OC_remoteStorage {
public static function getAllTokens() {
$user=OCP\USER::getUser();
- $query=OCP\DB::prepare("SELECT `token`,`appUrl`,`category` FROM `*PREFIX*authtoken` WHERE `user`=? LIMIT 100");
+ $query=OCP\DB::prepare("SELECT `token`,`appUrl`,`category` FROM `*PREFIX*authtoken` WHERE `user`=?",100);
$result=$query->execute(array($user));
$ret = array();
while($row=$result->fetchRow()){