diff options
author | matthiasgrimm <matthiasgrimm@users.sourceforge.net> | 2006-01-26 20:51:09 +0100 |
---|---|---|
committer | matthiasgrimm <matthiasgrimm@users.sourceforge.net> | 2006-01-26 20:51:09 +0100 |
commit | 36eaa3ebcd3613520ea17e50ac80acf59fd3b798 (patch) | |
tree | 5e22a45a7cb1a272dda7845f7c8555fb5ec6fd87 | |
parent | d87e576a120cdb1a4eccb748ab6eb1c34cc799b4 (diff) | |
download | rpg-36eaa3ebcd3613520ea17e50ac80acf59fd3b798.tar.gz rpg-36eaa3ebcd3613520ea17e50ac80acf59fd3b798.tar.bz2 |
MySQL retrieveUsers() use LIMIT
The function retrieveUsers() uses the SQL statement LIMIT now
to select a subset of tupel out of a result table instead of
fetching the whole table and filter in PHP.
darcs-hash:20060126195109-7ef76-79af82f95282d43b585a67b495bfa86c2f5e3a15.gz
-rw-r--r-- | inc/auth/mysql.class.php | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/inc/auth/mysql.class.php b/inc/auth/mysql.class.php index a5fda82e5..2642ebd4c 100644 --- a/inc/auth/mysql.class.php +++ b/inc/auth/mysql.class.php @@ -184,10 +184,12 @@ class auth_mysql extends auth_basic { $grpdel = array_diff($groups, $changes['grps']); foreach($grpadd as $group) - $this->_addUserToGroup($uid, $group, 1); + if (($this->_addUserToGroup($uid, $group, 1)) == false) + $rc = false; foreach($grpdel as $group) - $this->_delUserFromGroup($uid, $group); + if (($this->_delUserFromGroup($uid, $group)) == false) + $rc = false; } } @@ -251,33 +253,26 @@ class auth_mysql extends auth_basic { /** * Bulk retrieval of user data. [public function] * - * @param start index of first user to be returned + * @param first index of first user to be returned * @param limit max number of users to be returned * @param filter array of field/pattern pairs * @return array of userinfo (refer getUserData for internal userinfo details) * * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> */ - function retrieveUsers($start=0,$limit=0,$filter=array()) { + function retrieveUsers($first=0,$limit=10,$filter=array()) { $out = array(); - $i = 0; - $count = 0; - + if($this->_openDB()) { $this->_lockTables("READ"); - $sql = $this->_createSQLFilter($this->cnf['getUsers'], $filter)." ".$this->cnf['SortOrder']; + $sql = $this->_createSQLFilter($this->cnf['getUsers'], $filter); + $sql .= " ".$this->cnf['SortOrder']." LIMIT $first,$limit"; $result = $this->_queryDB($sql); - if ($result) { - foreach ($result as $user) { - if ($i++ >= $start) { - $info = $this->_getUserInfo($user['user']); - if ($info) { - $out[$user['user']] = $info; - if (($limit > 0) && (++$count >= $limit)) break; - } - } - } - } + + foreach ($result as $user) + if (($info = $this->_getUserInfo($user['user']))) + $out[$user['user']] = $info; + $this->_unlockTables(); $this->_closeDB(); } |