summaryrefslogtreecommitdiff
path: root/framework/Data/SqlMap/Statements/TPreparedCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/SqlMap/Statements/TPreparedCommand.php')
-rw-r--r--framework/Data/SqlMap/Statements/TPreparedCommand.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/framework/Data/SqlMap/Statements/TPreparedCommand.php b/framework/Data/SqlMap/Statements/TPreparedCommand.php
new file mode 100644
index 00000000..5a8041ae
--- /dev/null
+++ b/framework/Data/SqlMap/Statements/TPreparedCommand.php
@@ -0,0 +1,29 @@
+<?php
+
+class TPreparedCommand
+{
+
+ public function create(TSqlMapManager $manager, $connection, $statement, $parameterObject)
+ {
+ $prepared = $statement->getSQLText()->getPreparedStatement($parameterObject);
+ $connection->setActive(true);
+ $command = $connection->createCommand($prepared->getPreparedSql());
+ $this->applyParameterMap($manager, $command, $prepared, $statement, $parameterObject);
+ return $command;
+ }
+
+ protected function applyParameterMap($manager,$command,$prepared, $statement, $parameterObject)
+ {
+ $properties = $prepared->getParameterNames();
+ $parameters = $prepared->getParameterValues();
+ $registry=$manager->getTypeHandlers();
+ for($i = 0, $k=$properties->getCount(); $i<$k; $i++)
+ {
+ $property = $statement->parameterMap()->getProperty($i);
+ $value = $statement->parameterMap()->getPropertyValue($registry,$property, $parameterObject);
+ $command->bindValue($i+1,$value);
+ }
+ }
+}
+
+?> \ No newline at end of file