diff options
Diffstat (limited to 'lib/prado/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php')
-rw-r--r-- | lib/prado/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/prado/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php b/lib/prado/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php new file mode 100644 index 0000000..11f8a56 --- /dev/null +++ b/lib/prado/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php @@ -0,0 +1,38 @@ +<?php +/** + * TSimpleDynamicSql class file. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @link https://github.com/pradosoft/prado + * @copyright Copyright © 2005-2015 The PRADO Group + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT + * @package System.Data.SqlMap.Statements + */ + +/** + * TSimpleDynamicSql class. + * + * @author Wei Zhuo <weizho[at]gmail[dot]com> + * @package System.Data.SqlMap.Statements + * @since 3.1 + */ +class TSimpleDynamicSql extends TStaticSql +{ + private $_mappings=array(); + + public function __construct($mappings) + { + $this->_mappings = $mappings; + } + + public function replaceDynamicParameter($sql, $parameter) + { + foreach($this->_mappings as $property) + { + $value = TPropertyAccess::get($parameter, $property); + $sql = preg_replace('/'.TSimpleDynamicParser::DYNAMIC_TOKEN.'/', str_replace('$', '\$', $value), $sql, 1); + } + return $sql; + } +} + |