| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/dbal/src/drivers/lmbDbConnection.interface.php'); 10 lmb_require('limb/core/src/lmbDecorator.class.php'); 11 12 lmbDecorator :: generate('lmbDbConnection', 'lmbDbConnectionDecorator'); 13 14 /** 15 * class lmbAutoTransactionConnection. 16 * 17 * @package dbal 18 * @version $Id: lmbAutoTransactionConnection.class.php 5945 2007-06-06 08:31:43Z pachanga $ 19 */ 20 class lmbAutoTransactionConnection extends lmbDbConnectionDecorator 21 { 22 protected $modifying_statements = array('UPDATE', 23 'DELETE', 24 'INSERT', 25 'CREATE', 26 'ALTER', 27 'DROP');//do we need more? 28 protected $is_in_transaction = false; 29 30 function newStatement($sql) 31 { 32 if($this->_isModifyingSQL($sql)) 33 $this->beginTransaction(); 34 35 return parent :: newStatement($sql); 36 } 37 38 protected function _isModifyingSQL($sql) 39 { 40 $sql_trimmed = ltrim($sql); 41 42 foreach($this->modifying_statements as $stmt) 43 { 44 if(stripos($sql_trimmed, $stmt . ' ') === 0) 45 return true; 46 } 47 return false; 48 } 49 50 function beginTransaction() 51 { 52 if($this->is_in_transaction) 53 return; 54 parent :: beginTransaction(); 55 $this->is_in_transaction = true; 56 } 57 58 function commitTransaction() 59 { 60 if($this->is_in_transaction) 61 { 62 parent :: commitTransaction(); 63 $this->is_in_transaction = false; 64 } 65 } 66 67 function rollbackTransaction() 68 { 69 if($this->is_in_transaction) 70 { 71 parent :: rollbackTransaction(); 72 $this->is_in_transaction = false; 73 } 74 } 75 76 function isInTransaction() 77 { 78 return $this->is_in_transaction; 79 } 80 } 81 82 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |