diff options
Diffstat (limited to 'src/SemanticScuttle')
-rw-r--r-- | src/SemanticScuttle/db/sqlite.php | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/SemanticScuttle/db/sqlite.php b/src/SemanticScuttle/db/sqlite.php index 4531d17..f34be28 100644 --- a/src/SemanticScuttle/db/sqlite.php +++ b/src/SemanticScuttle/db/sqlite.php @@ -27,7 +27,6 @@ class sql_db var $db_connection; var $query_result; var $return_on_error = false; - var $transaction = false; var $sql_report = ''; var $sql_time = 0; var $num_queries = 0; @@ -42,6 +41,8 @@ class sql_db public $QueryBuilder; + private int $transaction_level = 0; + public function __construct() { $this->QueryBuilder = new SQLiteQueryBuilder(); @@ -85,19 +86,34 @@ class sql_db switch ($status) { case 'begin': - $this->transaction = true; - $result = $this->db_connection->exec('BEGIN'); - break; + $this->transaction_level++; + if ($this->transaction_level == 1) { + $result = $this->db_connection->exec('BEGIN'); + break; + } + else { + $result = true; + } case 'commit': - $this->transaction = false; - $result = $this->db_connection->exec('COMMIT'); - break; + $this->transaction_level--; + if ($this->transaction_level == 0) { + $result = $this->db_connection->exec('COMMIT'); + break; + } + else { + $result = true; + } case 'rollback': - $this->transaction = false; - $result = $this->db_connection->exec('ROLLBACK'); - break; + $this->transaction_level--; + if ($this->transaction_level == 0) { + $result = $this->db_connection->exec('ROLLBACK'); + break; + } + else { + $result = true; + } default: $result = true; @@ -401,7 +417,7 @@ class sql_db $message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . $this->db_connection->lastErrorMsg() . '<br /><br /><u>CALLING PAGE</u><br /><br />' . htmlspecialchars($this_page) . (($sql != '') ? '<br /><br /><u>SQL</u><br /><br />' . $sql : '') . '<br />'; - if ($this->transaction) + while ($this->transaction_level > 0) { $this->sql_transaction('rollback'); } |