mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-01 16:11:20 +00:00
Add transaction helpers to query class.
This commit is contained in:
parent
ecf57ce54e
commit
e2ff9b575b
@ -95,6 +95,7 @@ class AwlDatabase extends AwlDBDialect {
|
|||||||
else {
|
else {
|
||||||
trigger_error("Cannot begin a transaction while a transaction is already active.", E_USER_ERROR);
|
trigger_error("Cannot begin a transaction while a transaction is already active.", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ class AwlDatabase extends AwlDBDialect {
|
|||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
$this->txnstate = 0;
|
$this->txnstate = 0;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,6 +122,7 @@ class AwlDatabase extends AwlDBDialect {
|
|||||||
else {
|
else {
|
||||||
trigger_error("Cannot rollback unless a transaction is already active.", E_USER_ERROR);
|
trigger_error("Cannot rollback unless a transaction is already active.", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -358,6 +358,41 @@ class AwlQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap the parent DB class Begin() so we can $qry->Begin() sometime before we $qry->Exec()
|
||||||
|
*/
|
||||||
|
public function Begin() {
|
||||||
|
global $_awl_dbconn;
|
||||||
|
if ( !isset($this->connection) ) {
|
||||||
|
if ( !isset($_awl_dbconn) ) _awl_connect_configured_database();
|
||||||
|
$this->connection = $_awl_dbconn;
|
||||||
|
}
|
||||||
|
return $this->connection->Begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap the parent DB class Commit() so we can $qry->Commit() sometime after we $qry->Exec()
|
||||||
|
*/
|
||||||
|
public function Commit() {
|
||||||
|
if ( !isset($this->connection) ) {
|
||||||
|
trigger_error("Cannot commit a transaction without an active statement.", E_USER_ERROR);
|
||||||
|
}
|
||||||
|
return $this->connection->Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap the parent DB class Rollback() so we can $qry->Rollback() sometime after we $qry->Exec()
|
||||||
|
*/
|
||||||
|
public function Rollback() {
|
||||||
|
if ( !isset($this->connection) ) {
|
||||||
|
trigger_error("Cannot rollback a transaction without an active statement.", E_USER_ERROR);
|
||||||
|
}
|
||||||
|
return $this->connection->Rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the query, logging any debugging.
|
* Execute the query, logging any debugging.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user