| [ 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/query/lmbTemplateQuery.class.php'); 10 11 define('LIMB_INSERT_QUERY_NON_VALUE', uniqid()); 12 13 /** 14 * class lmbInsertQuery. 15 * 16 * @package dbal 17 * @version $Id: lmbInsertQuery.class.php 6005 2007-06-19 21:14:49Z pachanga $ 18 */ 19 class lmbInsertQuery extends lmbTemplateQuery 20 { 21 protected $_table; 22 protected $_fields = array(); 23 protected $_set_values = array(); 24 25 function __construct($table, $conn) 26 { 27 $this->_table = $table; 28 parent :: __construct("INSERT INTO %table% (%fields%) VALUES (%values%)", $conn); 29 } 30 31 function addField($field, $value = LIMB_INSERT_QUERY_NON_VALUE) 32 { 33 $this->_fields[$field] = $value; 34 } 35 36 protected function _getTableHint() 37 { 38 return $this->_conn->quoteIdentifier($this->_table); 39 } 40 41 protected function _getFieldsHint() 42 { 43 return implode(',', array_map(array($this->_conn, 'quoteIdentifier'), array_keys($this->_fields))); 44 } 45 46 protected function _getValuesHint() 47 { 48 $values = array(); 49 foreach($this->_fields as $field => $value) 50 { 51 if($value !== LIMB_INSERT_QUERY_NON_VALUE) 52 $this->_set_values[$field] = $value; 53 54 $values[] = ":{$field}:"; 55 } 56 57 return implode(',', $values); 58 } 59 60 function getStatement() 61 { 62 $stmt = parent :: getStatement(); 63 foreach($this->_set_values as $key => $value) 64 $stmt->set($key, $value); 65 66 return $stmt; 67 } 68 69 } 70 ?>
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 |