| [ 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 lmb_require('limb/dbal/src/criteria/lmbSQLCriteria.class.php'); 11 12 /** 13 * class lmbCriteriaQuery. 14 * 15 * @package dbal 16 * @version $Id: lmbCriteriaQuery.class.php 6005 2007-06-19 21:14:49Z pachanga $ 17 */ 18 class lmbCriteriaQuery extends lmbTemplateQuery 19 { 20 protected $_criterias; 21 protected $_stmt_values = array(); 22 23 function addCriteria($criteria) 24 { 25 $this->_criterias[] = lmbSQLCriteria :: objectify($criteria); 26 } 27 28 function getStatementValues() 29 { 30 return $this->_stmt_values; 31 } 32 33 function getStatement() 34 { 35 $stmt = parent :: getStatement(); 36 37 foreach($this->_stmt_values as $key => $value) 38 $stmt->set($key, $value); 39 40 return $stmt; 41 } 42 43 protected function _getWhereHint() 44 { 45 if(count($this->_criterias) == 0) 46 return ''; 47 48 $implode = array(); 49 foreach($this->_criterias as $criteria) 50 { 51 $implode[] = $criteria->toStatementString($this->_stmt_values); 52 } 53 54 $where = implode(' AND ', $implode); 55 56 if($this->_whereClauseExists($where_args)) 57 { 58 if($where_args) 59 return 'AND ' . $where; 60 else 61 return $where; 62 } 63 else 64 return 'WHERE ' . $where; 65 } 66 67 protected function _whereClauseExists(&$args = array()) 68 { 69 //primitive check if WHERE was already in sql 70 //!!!make it better later 71 if(preg_match('~(?<=\Wfrom).+\Wwhere\s+(.*)~si', $this->_getNoHintsSQL(), $matches)) 72 { 73 if(preg_match('~([a-zA-Z].*)$~si', $matches[1], $args_matches)) 74 $args = $args_matches[1]; 75 return true; 76 } 77 return false; 78 } 79 } 80 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |