aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-09-17 02:36:04 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-09-17 02:36:04 +0200
commit5e3ecbbf96ff0268220a85aaef3c99c84e13ab44 (patch)
tree166926872f4e172041527076cae40ecbb1fa7da0 /lib
parent0e2b957dacb86c510c59721f63879f1c9d93d5d4 (diff)
downloadnextcloud-server-5e3ecbbf96ff0268220a85aaef3c99c84e13ab44.tar.gz
nextcloud-server-5e3ecbbf96ff0268220a85aaef3c99c84e13ab44.zip
dont use numRows when it's not needed since it can be expensive
Diffstat (limited to 'lib')
-rw-r--r--lib/appconfig.php10
-rw-r--r--lib/group/database.php2
-rw-r--r--lib/preferences.php11
-rw-r--r--lib/user/database.php4
4 files changed, 12 insertions, 15 deletions
diff --git a/lib/appconfig.php b/lib/appconfig.php
index c64a15b8938..392782b2586 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -93,14 +93,12 @@ class OC_Appconfig{
// At least some magic in here :-)
$query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*appconfig WHERE appid = ? AND configkey = ?' );
$result = $query->execute( array( $app, $key ));
-
- if( !$result->numRows()){
+ $row = $result->fetchRow();
+ if($row){
+ return $row["configvalue"];
+ }else{
return $default;
}
-
- $row = $result->fetchRow();
-
- return $row["configvalue"];
}
/**
diff --git a/lib/group/database.php b/lib/group/database.php
index 8a9fc53d39f..7bf9c8bb5ce 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -56,7 +56,7 @@ class OC_Group_Database extends OC_Group_Backend {
$query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups` WHERE gid = ?" );
$result = $query->execute( array( $gid ));
- if( $result->numRows() > 0 ){
+ if( !$result->fetchRow() ){
// Can not add an existing group
return false;
}
diff --git a/lib/preferences.php b/lib/preferences.php
index d53cdd538e0..5af007f0223 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -116,14 +116,13 @@ class OC_Preferences{
// Try to fetch the value, return default if not exists.
$query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' );
$result = $query->execute( array( $user, $app, $key ));
-
- if( !$result->numRows()){
+
+ $row = $result->fetchRow();
+ if($row){
+ return $row["configvalue"];
+ }else{
return $default;
}
-
- $row = $result->fetchRow();
-
- return $row["configvalue"];
}
/**
diff --git a/lib/user/database.php b/lib/user/database.php
index f29aaf00f05..452709c1fb9 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -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 = ?" );
$result = $query->execute( array( $uid, sha1( $password )));
- if( $result->numRows() > 0 ){
- $row=$result->fetchRow();
+ $row=$result->fetchRow();
+ if($row){
return $row['uid'];
}else{
return false;