diff options
author | godzilla80@gmx.net <> | 2009-03-22 08:02:35 +0000 |
---|---|---|
committer | godzilla80@gmx.net <> | 2009-03-22 08:02:35 +0000 |
commit | 466c414ebc9dde38e80f20fd96fd891431404fca (patch) | |
tree | 9934bdefe395804dc334b4d12637db345f97c8b5 /framework/Data | |
parent | 1624bf7d560af5789416af904e45975618adef8c (diff) |
Fixed Issue #88 - SQLMap $Param$ re-evaluation bug
Diffstat (limited to 'framework/Data')
-rw-r--r-- | framework/Data/SqlMap/Statements/TPreparedCommand.php | 9 | ||||
-rw-r--r-- | framework/Data/SqlMap/Statements/TSimpleDynamicSql.php | 14 |
2 files changed, 11 insertions, 12 deletions
diff --git a/framework/Data/SqlMap/Statements/TPreparedCommand.php b/framework/Data/SqlMap/Statements/TPreparedCommand.php index 99bb6eff..66ff2a70 100644 --- a/framework/Data/SqlMap/Statements/TPreparedCommand.php +++ b/framework/Data/SqlMap/Statements/TPreparedCommand.php @@ -25,9 +25,15 @@ class TPreparedCommand {
public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject,$skip=null,$max=null)
{
- $prepared = $statement->getSQLText()->getPreparedStatement($parameterObject);
+ $sqlText = $statement->getSQLText();
+
+ $prepared = $sqlText->getPreparedStatement($parameterObject);
$connection->setActive(true);
$sql = $prepared->getPreparedSql();
+
+ if($sqlText instanceof TSimpleDynamicSql)
+ $sql = $sqlText->replaceDynamicParameter($sql, $parameterObject);
+
if($max!==null || $skip!==null)
{
$builder = TDbMetaData::getInstance($connection)->createCommandBuilder();
@@ -35,6 +41,7 @@ class TPreparedCommand }
$command = $connection->createCommand($sql);
$this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject);
+
return $command;
}
diff --git a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php index 910fd659..3e8969ba 100644 --- a/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php +++ b/framework/Data/SqlMap/Statements/TSimpleDynamicSql.php @@ -27,23 +27,15 @@ class TSimpleDynamicSql extends TStaticSql $this->_mappings = $mappings;
}
- public function getPreparedStatement($parameter=null)
+ public function replaceDynamicParameter($sql, $parameter)
{
- $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);
+
+ return $sql;
}
}
|