Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Use %lmt and %ofs instead of LIMIT for dibi queries
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
  • Loading branch information
Etienne CHAMPETIER committed Oct 7, 2013
1 parent b1ccdf3 commit 4a45efe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/auth.sql/class.sqlAuthDriver.php
Expand Up @@ -63,7 +63,7 @@ public function listUsersPaginated($baseGroup = "/", $regexp, $offset, $limit)
else if($regexp[strlen($regexp)-1] == "$") $regexp = "%".rtrim($regexp, "$");
$res = dibi::query("SELECT * FROM [ajxp_users] WHERE [login] LIKE '".$regexp."' AND [groupPath] LIKE %s ORDER BY [login] ASC", $baseGroup."%") ;
} else if ($offset != -1 || $limit != -1) {
$res = dibi::query("SELECT * FROM [ajxp_users] WHERE [groupPath] LIKE %s ORDER BY [login] ASC LIMIT $offset,$limit", $baseGroup."%");
$res = dibi::query("SELECT * FROM [ajxp_users] WHERE [groupPath] LIKE %s ORDER BY [login] ASC %lmt %ofs", $baseGroup."%", $limit, $offset);
} else {
$res = dibi::query("SELECT * FROM [ajxp_users] WHERE [groupPath] LIKE %s ORDER BY [login] ASC", $baseGroup."%");
}
Expand Down
8 changes: 4 additions & 4 deletions core/src/plugins/feed.sql/class.AJXP_SqlFeedStore.php
Expand Up @@ -88,7 +88,7 @@ public function loadEvents($filterByRepositories, $userId, $userGroup, $offset =
OR ([repository_scope] = 'USER' AND [user_id] = %s )
OR ([repository_scope] = 'GROUP' AND [user_group] = %s )
)
ORDER BY [edate] DESC LIMIT $offset,$limit ", "event", $filterByRepositories, $userId, $userId, $userGroup);
ORDER BY [edate] DESC %lmt %ofs", "event", $filterByRepositories, $userId, $userId, $userGroup, $limit, $offset);
$data = array();
foreach ($res as $n => $row) {
$object = new stdClass();
Expand Down Expand Up @@ -136,9 +136,9 @@ public function loadAlerts($userId, $repositoryIdFilter = null)
require_once(AJXP_BIN_FOLDER."/dibi.compact.php");
dibi::connect($this->sqlDriver);
if ($repositoryIdFilter != null) {
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [repository_id] = %s AND [user_id] = %s ORDER BY [edate] DESC LIMIT 0,100 ", "alert", $repositoryIdFilter, $userId);
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [repository_id] = %s AND [user_id] = %s ORDER BY [edate] DESC %lmt", "alert", $repositoryIdFilter, $userId, 100);
} else {
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [user_id] = %s ORDER BY [edate] DESC LIMIT 0,100 ", "alert", $userId);
$res = dibi::query("SELECT * FROM [ajxp_feed] WHERE [etype] = %s AND [user_id] = %s ORDER BY [edate] DESC %lmt", "alert", $userId, 100);
}
$data = array();
foreach ($res as $n => $row) {
Expand Down Expand Up @@ -172,7 +172,7 @@ public function dismissAlertById($alertId, $occurrences = 1)
$startEventNotif = unserialize($startEventRow->content);
$url = $startEventNotif->getNode()->getUrl();
$date = $startEventRow->edate;
$newRes = dibi::query("SELECT [id] FROM [ajxp_feed] WHERE [etype] = %s AND [user_id] = %s AND [edate] <= %s AND content LIKE %s ORDER BY [edate] DESC LIMIT 0,$occurrences", "alert", $userId, $date, "%\"$url\"%");
$newRes = dibi::query("SELECT [id] FROM [ajxp_feed] WHERE [etype] = %s AND [user_id] = %s AND [edate] <= %s AND content LIKE %s ORDER BY [edate] DESC %lmt", "alert", $userId, $date, "%\"$url\"%", $occurrences);
$a = $newRes->fetchPairs();
dibi::query("DELETE FROM [ajxp_feed] WHERE [id] IN (%s)", $a);
}
Expand Down

0 comments on commit 4a45efe

Please sign in to comment.