Use count SQL to check for user existance

This commit is contained in:
Bart Visscher 2013-02-25 08:18:02 +01:00
parent e824c6cffa
commit 3213c47188
1 changed files with 2 additions and 2 deletions

View File

@ -237,13 +237,13 @@ class OC_User_Database extends OC_User_Backend {
* @return boolean
*/
public function userExists($uid) {
$query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' );
$query = OC_DB::prepare( 'SELECT COUNT(*) FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' );
$result = $query->execute( array( $uid ));
if (OC_DB::isError($result)) {
OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR);
return false;
}
return $result->numRows() > 0;
return $result->fetchColumn() > 0;
}
/**