summaryrefslogtreecommitdiff
path: root/lib/Minz/ModelPdo.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:45:37 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:45:37 +0100
commita97bbd9bd54c5fa56d54b3c214cf4e8af96af8b2 (patch)
tree6e83890bc1b3814a12c3b7bedc0d5944f30f507b /lib/Minz/ModelPdo.php
parent42fd539a1b14f883077048a35864b4294b6efe94 (diff)
parente91b72b63cd11ae3c4f59e48439e93955242c673 (diff)
Merge branch 'dev'
Conflicts: CHANGELOG README.fr.md README.md app/Controllers/feedController.php app/Controllers/indexController.php app/i18n/en.php app/i18n/fr.php app/views/helpers/view/normal_view.phtml app/views/stats/index.phtml app/views/stats/repartition.phtml constants.php p/scripts/main.js
Diffstat (limited to 'lib/Minz/ModelPdo.php')
-rw-r--r--lib/Minz/ModelPdo.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index b4bfca746..ac7a1bed7 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -16,6 +16,8 @@ class Minz_ModelPdo {
public static $useSharedBd = true;
private static $sharedBd = null;
private static $sharedPrefix;
+ private static $has_transaction = false;
+ private static $sharedCurrentUser;
protected static $sharedDbType;
/**
@@ -23,6 +25,7 @@ class Minz_ModelPdo {
*/
protected $bd;
+ protected $current_user;
protected $prefix;
public function dbType() {
@@ -37,14 +40,18 @@ class Minz_ModelPdo {
if (self::$useSharedBd && self::$sharedBd != null && $currentUser === null) {
$this->bd = self::$sharedBd;
$this->prefix = self::$sharedPrefix;
+ $this->current_user = self::$sharedCurrentUser;
return;
}
- $db = Minz_Configuration::dataBase();
+ $conf = Minz_Configuration::get('system');
+ $db = $conf->db;
if ($currentUser === null) {
$currentUser = Minz_Session::param('currentUser', '_');
}
+ $this->current_user = $currentUser;
+ self::$sharedCurrentUser = $currentUser;
try {
$type = $db['type'];
@@ -57,7 +64,7 @@ class Minz_ModelPdo {
);
$this->prefix = $db['prefix'] . $currentUser . '_';
} elseif ($type === 'sqlite') {
- $string = 'sqlite:' . DATA_PATH . '/' . $currentUser . '.sqlite';
+ $string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite');
$driver_options = array(
//PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
);
@@ -91,12 +98,18 @@ class Minz_ModelPdo {
public function beginTransaction() {
$this->bd->beginTransaction();
+ self::$has_transaction = true;
+ }
+ public function hasTransaction() {
+ return self::$has_transaction;
}
public function commit() {
$this->bd->commit();
+ self::$has_transaction = false;
}
public function rollBack() {
$this->bd->rollBack();
+ self::$has_transaction = false;
}
public static function clean() {