summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-10-13 00:17:12 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-10-13 00:17:12 +0200
commit410b47603a72947b33ae3cbe92968c8c824e194e (patch)
treed2ba6252caa7105d256d767b428d8272f668093f /lib
parentaa71754eeea171cbc37e49eee5eba0f2d4183693 (diff)
Optimisation SQL, deuxième vague
Réduction du nombre de requêtes et de connexions SQL
Diffstat (limited to 'lib')
-rwxr-xr-xlib/minz/dao/Model_pdo.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/minz/dao/Model_pdo.php b/lib/minz/dao/Model_pdo.php
index fa44038db..343b7004a 100755
--- a/lib/minz/dao/Model_pdo.php
+++ b/lib/minz/dao/Model_pdo.php
@@ -9,6 +9,14 @@
* Seul la connexion MySQL est prise en charge pour le moment
*/
class Model_pdo {
+
+ /**
+ * Partage la connexion à la base de données entre toutes les instances.
+ */
+ public static $useSharedBd = true;
+ private static $sharedBd = null;
+ private static $sharedPrefix;
+
/**
* $bd variable représentant la base de données
*/
@@ -21,6 +29,12 @@ class Model_pdo {
* HOST, BASE, USER et PASS définies dans le fichier de configuration
*/
public function __construct () {
+ if (self::$useSharedBd && self::$sharedBd != null) {
+ $this->bd = self::$sharedBd;
+ $this->prefix = self::$sharedPrefix;
+ return;
+ }
+
$db = Configuration::dataBase ();
$driver_options = null;
@@ -46,8 +60,10 @@ class Model_pdo {
$db['password'],
$driver_options
);
+ self::$sharedBd = $this->bd;
$this->prefix = $db['prefix'];
+ self::$sharedPrefix = $this->prefix;
} catch (Exception $e) {
throw new PDOConnectionException (
$string,