Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
0528937a
Commit
0528937a
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Minor improvements to SimpleSAML\Database.
parent
84547358
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SimpleSAML/Database.php
+16
-25
16 additions, 25 deletions
lib/SimpleSAML/Database.php
with
16 additions
and
25 deletions
lib/SimpleSAML/Database.php
+
16
−
25
View file @
0528937a
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment