ConnectionCommon.php

Go to the documentation of this file.
00001 <?php 00002 /* 00003 * $Id: ConnectionCommon.php,v 1.2 2004/03/20 04:16:49 hlellelid Exp $ 00004 * 00005 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00006 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00007 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00008 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00009 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00010 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00011 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00012 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00013 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00014 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00015 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00016 * 00017 * This software consists of voluntary contributions made by many individuals 00018 * and is licensed under the LGPL. For more information please see 00019 * <http://creole.phpdb.org>. 00020 */ 00021 00032 abstract class ConnectionCommon { 00033 00034 // Constants that define transaction isolation levels. 00035 // [We don't have any code using these yet, so there's no need 00036 // to initialize these values at this point.] 00037 // const TRANSACTION_NONE = 0; 00038 // const TRANSACTION_READ_UNCOMMITTED = 1; 00039 // const TRANSACTION_READ_COMMITTED = 2; 00040 // const TRANSACTION_REPEATABLE_READ = 3; 00041 // const TRANSACTION_SERIALIZABLE = 4; 00042 00047 protected $transactionOpcount = 0; 00048 00052 protected $autocommit = true; 00053 00058 protected $dblink; 00059 00064 protected $dsn; 00065 00070 protected $flags = 0; 00071 00099 public function __sleep() 00100 { 00101 return array('dsn', 'flags'); 00102 } 00103 00110 public function __wakeup() 00111 { 00112 $this->connect($this->dsn, $this->flags); 00113 } 00114 00118 public function getResource() 00119 { 00120 return $this->dblink; 00121 } 00122 00126 public function getDSN() { 00127 return $this->dsn; 00128 } 00129 00133 public function getFlags() 00134 { 00135 return $this->flags; 00136 } 00137 00144 public function prepareCall($sql) 00145 { 00146 throw new SQLException("Current driver does not support stored procedures using CallableStatement."); 00147 } 00148 00162 public function applyLimit(&$sql, $offset, $limit) 00163 { 00164 $sql .= " LIMIT ".$limit." OFFSET ".$offset; 00165 } 00166 00172 public function getAutoCommit() 00173 { 00174 return $this->autocommit; 00175 } 00176 00188 public function setAutoCommit($bit) 00189 { 00190 $this->autocommit = (boolean) $bit; 00191 if ($this->transactionOpcount > 0) { 00192 trigger_error("Changing autocommit in mid-transaction; committing " . $this->transactionOpcount . " uncommitted statements.", E_USER_WARNING); 00193 } 00194 if ($bit && $this->transactionOpcount > 0) { 00195 $this->commit(); 00196 } 00197 } 00198 00199 }

This file is part of the Creole[php5] library.


Copyright © 2004 Hans Lellelid  
Creole[php5] CVS