dont use numRows when it's not needed since it can be expensive

This commit is contained in:
Robin Appelman 2011-09-17 02:36:04 +02:00
parent d0d3fecc95
commit 8c7aa06088
4 changed files with 12 additions and 15 deletions

View File

@ -93,14 +93,12 @@ class OC_Appconfig{
// At least some magic in here :-) // At least some magic in here :-)
$query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*appconfig WHERE appid = ? AND configkey = ?' ); $query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*appconfig WHERE appid = ? AND configkey = ?' );
$result = $query->execute( array( $app, $key )); $result = $query->execute( array( $app, $key ));
$row = $result->fetchRow();
if( !$result->numRows()){ if($row){
return $row["configvalue"];
}else{
return $default; return $default;
} }
$row = $result->fetchRow();
return $row["configvalue"];
} }
/** /**

View File

@ -56,7 +56,7 @@ class OC_Group_Database extends OC_Group_Backend {
$query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups` WHERE gid = ?" ); $query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups` WHERE gid = ?" );
$result = $query->execute( array( $gid )); $result = $query->execute( array( $gid ));
if( $result->numRows() > 0 ){ if( !$result->fetchRow() ){
// Can not add an existing group // Can not add an existing group
return false; return false;
} }

View File

@ -117,13 +117,12 @@ class OC_Preferences{
$query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' ); $query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' );
$result = $query->execute( array( $user, $app, $key )); $result = $query->execute( array( $user, $app, $key ));
if( !$result->numRows()){ $row = $result->fetchRow();
if($row){
return $row["configvalue"];
}else{
return $default; return $default;
} }
$row = $result->fetchRow();
return $row["configvalue"];
} }
/** /**

View File

@ -106,8 +106,8 @@ class OC_User_Database extends OC_User_Backend {
$query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users WHERE uid LIKE ? AND password = ?" ); $query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users WHERE uid LIKE ? AND password = ?" );
$result = $query->execute( array( $uid, sha1( $password ))); $result = $query->execute( array( $uid, sha1( $password )));
if( $result->numRows() > 0 ){
$row=$result->fetchRow(); $row=$result->fetchRow();
if($row){
return $row['uid']; return $row['uid'];
}else{ }else{
return false; return false;