| [ 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/lmbDbInsertStatement.interface.php'); 10 lmb_require(dirname(__FILE__) . '/lmbOciManipulationStatement.class.php'); 11 12 /** 13 * class lmbOciInsertStatement. 14 * 15 * @package dbal 16 * @version $Id: lmbOciInsertStatement.class.php 5945 2007-06-06 08:31:43Z pachanga $ 17 */ 18 class lmbOciInsertStatement extends lmbOciManipulationStatement implements lmbDbInsertStatement 19 { 20 protected function _mapHolderToField($name, $sql) 21 { 22 // a very basic implementation 23 if(!preg_match('~INSERT[^\(]+\(([^\)]+)\)[^\(]+\(([^\)]+)~i', $sql, $m)) 24 throw new lmbDbException("Could not map placeholder :p_$name to field in '$sql'"); 25 26 $fields = array_map('trim', explode(',', $m[1])); 27 $values = array_map('trim', explode(',', $m[2])); 28 29 if(sizeof($fields) !== sizeof($values)) 30 throw new lmbDbException("Amount of fields does not match amount of values in '$sql'"); 31 32 for($i=0;$i<sizeof($values);$i++) 33 { 34 if($values[$i] == ":p_$name") 35 return strtolower(trim($fields[$i], '"')); 36 } 37 38 throw new lmbDbException("Could not map placeholder :p_$name to field in '$sql'"); 39 } 40 41 function insertId($field_name = 'id') 42 { 43 $this->execute(); 44 45 if(isset($this->parameters[$field_name]) && !empty($this->parameters[$field_name])) 46 return $this->parameters[$field_name]; 47 else 48 return $this->connection->getSequenceValue($this->_retriveTableName($this->getSQL()), $field_name); 49 } 50 51 protected function _retriveTableName($sql) 52 { 53 if(!preg_match('/INSERT\s+INTO\s+(\S+)/i', $sql, $m)) 54 throw new lmbDbException("Could not retrieve table name from query '$sql'"); 55 return $m[1]; 56 } 57 } 58 59 ?>
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 |