00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00032 abstract class ConnectionCommon {
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00047 protected $transactionOpcount = 0;
00048
00053 protected $dblink;
00054
00059 protected $dsn;
00060
00065 protected $flags = 0;
00066
00094 public function __sleep()
00095 {
00096 return array('dsn', 'flags');
00097 }
00098
00105 public function __wakeup()
00106 {
00107 $this->connect($this->dsn, $this->flags);
00108 }
00109
00113 public function getResource()
00114 {
00115 return $this->dblink;
00116 }
00117
00121 public function getDSN() {
00122 return $this->dsn;
00123 }
00124
00128 public function getFlags()
00129 {
00130 return $this->flags;
00131 }
00132
00139 public function prepareCall($sql)
00140 {
00141 throw new SQLException("Current driver does not support stored procedures using CallableStatement.");
00142 }
00143
00149 public function supportsNestedTrans()
00150 {
00151 return false;
00152 }
00153
00157 public function begin()
00158 {
00159 if ($this->transactionOpcount === 0 || $this->supportsNestedTrans()) {
00160 $this->beginTrans();
00161 }
00162 $this->transactionOpcount++;
00163 }
00164
00168 public function commit()
00169 {
00170 if ($this->transactionOpcount > 0) {
00171 if ($this->transactionOpcount == 1 || $this->supportsNestedTrans()) {
00172 $this->commitTrans();
00173 }
00174 $this->transactionOpcount--;
00175 }
00176 }
00177
00181 public function rollback()
00182 {
00183 if ($this->transactionOpcount > 0) {
00184 if ($this->transactionOpcount == 1 || $this->supportsNestedTrans()) {
00185 $this->rollbackTrans();
00186 }
00187 $this->transactionOpcount--;
00188 }
00189 }
00190
00202 public function setAutoCommit($bit)
00203 {
00204 if ($this->transactionOpcount > 0) {
00205 trigger_error("Changing autocommit in mid-transaction; committing " . $this->transactionOpcount . " uncommitted statements.", E_USER_WARNING);
00206 }
00207
00208 if (!$bit) {
00209 $this->begin();
00210 }
00211 else {
00212 $this->commit();
00213 }
00214 }
00215
00221 public function getAutoCommit()
00222 {
00223 return ($this->transactionOpcount == 0);
00224 }
00225
00230 protected function beginTrans()
00231 {
00232 }
00233
00238 protected function commitTrans()
00239 {
00240 }
00241
00246 protected function rollbackTrans()
00247 {
00248 }
00249
00254 public function isConnected()
00255 {
00256 return !empty($this->dblink);
00257 }
00258 }