Back to index

awl  0.53
AwlDatabase.php
Go to the documentation of this file.
00001 <?php
00037 require_once('AwlDBDialect.php');
00038 
00039 if ( !defined('E_USER_ERROR') ) define('E_USER_ERROR',256);
00040 
00041 
00058 class AwlDatabase extends AwlDBDialect {
00066   protected $txnstate = 0;
00067 
00071   protected $translate_all = false;
00072 
00080   function prepare( $statement, $driver_options = array() ) {
00081     if ( isset($this->translate_all) && $this->translate_all ) {
00082       $statement = $this->TranslateSQL( $statement );
00083     }
00084     return $this->db->prepare( $statement, $driver_options );
00085   }
00086 
00087 
00093   function query( $statement ) {
00094     return $this->db->query( $statement );
00095   }
00096 
00097 
00101   function Begin() {
00102     if ( $this->txnstate == 0 ) {
00103       $this->db->beginTransaction();
00104       $this->txnstate = 1;
00105     }
00106     else {
00107       fatal("Cannot begin a transaction while a transaction is already active.");
00108     }
00109     return true;
00110   }
00111 
00112 
00116   function Commit() {
00117     if ( $this->txnstate != 0 ) {
00118       $this->db->commit();
00119       $this->txnstate = 0;
00120     }
00121     return true;
00122   }
00123 
00124 
00128   function Rollback() {
00129     if ( $this->txnstate != 0 ) {
00130       $this->db->rollBack();
00131       $this->txnstate = 0;
00132     }
00133     else {
00134       throw new Exception("Cannot rollback unless a transaction is already active.");
00135     }
00136     return true;
00137   }
00138 
00139 
00145   function TransactionState() {
00146     return $this->txnstate;
00147   }
00148 
00149 
00154   function PrepareTranslated( $statement, $driver_options = array() ) {
00155     $statement = $this->TranslateSQL( $statement );
00156     return $this->prepare( $statement, $driver_options );
00157   }
00158 
00159 
00164   function TranslateAll( $onoff_boolean ) {
00165     $this->translate_all = $onoff_boolean;
00166     return $onoff_boolean;
00167   }
00168 
00169 
00173   function ErrorInfo() {
00174     return $this->db->errorInfo();
00175   }
00176 
00177 }
00178 
00179