| [ 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 10 /** 11 * class lmbTemplateQuery. 12 * 13 * @package dbal 14 * @version $Id: lmbTemplateQuery.class.php 6005 2007-06-19 21:14:49Z pachanga $ 15 */ 16 class lmbTemplateQuery 17 { 18 protected $_template_sql; 19 protected $_no_hints_sql; 20 protected $_conn; 21 protected $_hints; 22 23 function __construct($template_sql, $conn) 24 { 25 $this->_template_sql = $template_sql; 26 $this->_conn = $conn; 27 } 28 29 protected function _declareHints() 30 { 31 if($this->_hints !== null) 32 return $this->_hints; 33 34 if(preg_match_all('~%([a-z_]+)%~', $this->_template_sql, $m)) 35 $this->_hints = $m[1]; 36 else 37 $this->_hints = array(); 38 return $this->_hints; 39 } 40 41 function _wrapHint($hint) 42 { 43 return "%$hint%"; 44 } 45 46 function _getWrappedHints() 47 { 48 return array_map(array($this, '_wrapHint'), $this->_declareHints()); 49 } 50 51 function _fillHints() 52 { 53 $hints = $this->_declareHints(); 54 $result = array(); 55 foreach($hints as $hint) 56 { 57 $method = '_get' . lmb_camel_case($hint) . 'Hint'; 58 $result[$this->_wrapHint($hint)] = $this->$method(); 59 } 60 return $result; 61 } 62 63 function toString() 64 { 65 $hints = $this->_fillHints(); 66 return trim(strtr($this->_template_sql, $hints)); 67 } 68 69 function getStatement() 70 { 71 return $this->_conn->newStatement($this->toString()); 72 } 73 74 protected function _getNoHintsSQL() 75 { 76 if($this->_no_hints_sql) 77 return $this->_no_hints_sql; 78 79 $result = array(); 80 foreach($this->_getWrappedHints() as $hint) 81 $result[$hint] = ''; 82 83 $this->_no_hints_sql = strtr($this->_template_sql, $result); 84 return $this->_no_hints_sql; 85 } 86 } 87 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Oct 15 04:31:08 2008 | Cross-referenced by PHPXref 0.7 |