summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2016-02-17 15:20:38 +0100
committerJaime Perez Crespo <jaime.perez@uninett.no>2016-02-17 15:24:43 +0100
commit0528937a781d57a026c78fde510d200d74cdb763 (patch)
treebac018d27d859b574893c52a9d9c46c225ccfcf4 /lib/SimpleSAML
parent84547358ec38473cc1725affbebde7fe7c945bd1 (diff)
downloadsimplesamlphp-0528937a781d57a026c78fde510d200d74cdb763.zip
simplesamlphp-0528937a781d57a026c78fde510d200d74cdb763.tar.gz
simplesamlphp-0528937a781d57a026c78fde510d200d74cdb763.tar.bz2
Minor improvements to SimpleSAML\Database.
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/Database.php41
1 files changed, 16 insertions, 25 deletions
diff --git a/lib/SimpleSAML/Database.php b/lib/SimpleSAML/Database.php
index 1012e11..b703557 100644
--- a/lib/SimpleSAML/Database.php
+++ b/lib/SimpleSAML/Database.php
@@ -2,17 +2,15 @@
namespace SimpleSAML;
/**
- * This file implements functions to read and write to a group of database
- * servers.
+ * This file implements functions to read and write to a group of database servers.
*
- * This database class supports a single database, or a master/slave
- * configuration with as many defined slaves as a user would like.
+ * This database class supports a single database, or a master/slave configuration with as many defined slaves as a
+ * user would like.
*
- * The goal of this class is to provide a single mechanism to connect to a database
- * that can be reused by any component within SimpleSAMLphp including modules.
- * When using this class, the global configuration should be passed here, but
- * in the case of a module that has a good reason to use a different database,
- * such as sqlauth, an alternative config file can be provided.
+ * The goal of this class is to provide a single mechanism to connect to a database that can be reused by any component
+ * within SimpleSAMLphp including modules. When using this class, the global configuration should be passed here, but in
+ * the case of a module that has a good reason to use a different database, such as sqlauth, an alternative config file
+ * can be provided.
*
* @author Tyler Antonio, University of Alberta. <tantonio@ualberta.ca>
* @package SimpleSAMLphp
@@ -32,8 +30,7 @@ class Database
private $dbMaster;
/**
- * Array of PDO Objects for configured database
- * slaves
+ * Array of PDO Objects for configured database slaves
*/
private $dbSlaves = array();
@@ -112,8 +109,7 @@ class Database
/**
- * Generate an Instance ID based on the database
- * configuration.
+ * Generate an Instance ID based on the database configuration.
*
* @param \SimpleSAML_Configuration $config Configuration class
*
@@ -161,9 +157,8 @@ class Database
/**
- * This function randomly selects a slave database server
- * to query. In the event no slaves are configured, it
- * will return the master.
+ * This function randomly selects a slave database server to query. In the event no slaves are configured, it will
+ * return the master.
*
* @return \PDO object
*/
@@ -229,14 +224,13 @@ class Database
/**
- * This function queries the database without using a
- * prepared statement.
+ * This function queries the database without using a prepared statement.
*
* @param \PDO $db PDO object to use
- * @param string $stmt Prepared SQL statement
+ * @param string $stmt An SQL statement to execute, previously escaped.
*
* @throws \Exception If an error happens while trying to execute the query.
- * @return \PDOStatement object
+ * @return int The number of rows affected.
*/
private function exec($db, $stmt)
{
@@ -244,9 +238,7 @@ class Database
assert('is_string($stmt)');
try {
- $query = $db->exec($stmt);
-
- return $query;
+ return $db->exec($stmt);
} catch (\PDOException $e) {
$this->lastError = $db->errorInfo();
throw new \Exception("Database error: ".$e->getMessage());
@@ -276,8 +268,7 @@ class Database
/**
- * This executes queries on a database server
- * that is determined by this::getSlave()
+ * This executes queries on a database server that is determined by this::getSlave().
*
* @param string $stmt Prepared SQL statement
* @param array $params Parameters