diff options
author | wei <> | 2006-12-04 00:02:23 +0000 |
---|---|---|
committer | wei <> | 2006-12-04 00:02:23 +0000 |
commit | 18ea316c553f7ccfc18b73f0c987de007f11b275 (patch) | |
tree | b8fa0d14de75582b48c3e4d12050c84f07805920 /framework/Data/SqlMap/Statements/TSimpleDynamicSql.php | |
parent | b69ca04f50ffd538239342f3bfd1e77ffc6156c0 (diff) |
Fixed #469
Diffstat (limited to 'framework/Data/SqlMap/Statements/TSimpleDynamicSql.php')
-rw-r--r-- | framework/Data/SqlMap/Statements/TSimpleDynamicSql.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php new file mode 100644 index 00000000..1230b4f7 --- /dev/null +++ b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php @@ -0,0 +1,32 @@ +<?php
+
+class TSimpleDynamicSql extends TStaticSql
+{
+ private $_mappings=array();
+
+ public function __construct($mappings)
+ {
+ $this->_mappings = $mappings;
+ }
+
+ public function getPreparedStatement($parameter=null)
+ {
+ $statement = parent::getPreparedStatement($parameter);
+ if($parameter !== null)
+ $this->mapDynamicParameter($statement, $parameter);
+ return $statement;
+ }
+
+ protected function mapDynamicParameter($statement, $parameter)
+ {
+ $sql = $statement->getPreparedSql();
+ foreach($this->_mappings as $property)
+ {
+ $value = TPropertyAccess::get($parameter, $property);
+ $sql = preg_replace('/'.TSimpleDynamicParser::DYNAMIC_TOKEN.'/', $value, $sql, 1);
+ }
+ $statement->setPreparedSql($sql);
+ }
+}
+
+?>
\ No newline at end of file |