Merge pull request #2746 from owncloud/use-count-userexists

Use count SQL to check for user existance
This commit is contained in:
Thomas Tanghus 2013-04-17 03:06:50 -07:00
commit ec280e6f9f
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->fetchOne() > 0;
}
/**