summaryrefslogtreecommitdiff
path: root/framework/DataAccess/SQLMap/Statements/TPreparedCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/DataAccess/SQLMap/Statements/TPreparedCommand.php')
-rw-r--r--framework/DataAccess/SQLMap/Statements/TPreparedCommand.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/framework/DataAccess/SQLMap/Statements/TPreparedCommand.php b/framework/DataAccess/SQLMap/Statements/TPreparedCommand.php
new file mode 100644
index 00000000..1c0e5ad7
--- /dev/null
+++ b/framework/DataAccess/SQLMap/Statements/TPreparedCommand.php
@@ -0,0 +1,60 @@
+<?php
+
+class TPreparedCommand
+{
+
+ public function create($connection, $statement, $parameterObject)
+ {
+ $prepared = $statement->getSQL()->getPreparedStatement();
+ $parameters = $this->applyParameterMap($connection,
+ $prepared, $statement, $parameterObject);
+ return array('sql'=>$prepared->getPreparedSql(),
+ 'parameters'=>$parameters);
+ }
+
+ protected function applyParameterMap($connection,
+ $prepared, $statement, $parameterObject)
+ {
+ $properties = $prepared->getParameterNames();
+ $parameters = $prepared->getParameterValues();
+ $values = array();
+ for($i = 0, $k=$properties->getCount(); $i<$k; $i++)
+ {
+ $property = $statement->parameterMap()->getProperty($i);
+ $values[] = $statement->parameterMap()->getParameter(
+ $property, $parameterObject, $statement);
+ }
+ return count($values) > 0 ? $values : false;
+ }
+
+/* protected function applyParameterClass($connection, $statement, $parameter)
+ {
+ $type=$statement->getParameterClass();
+ if(strlen($type) < 1) return;
+ $prepared = $statement->getSql()->getPreparedStatement();
+ $names = $prepared->getParameterNames();
+ $values = $prepared->getParameterValues();
+ switch (strtolower($type))
+ {
+ case 'integer':
+ case 'int':
+ $values[$names[0]] = $connection->quote(intval($parameter));
+ break;
+ case 'array':
+ foreach($names as $name)
+ {
+ $key = substr(substr($name,0,-1),1);
+ if(isset($parameter[$key]))
+ $values->add($name,$connection->quote($parameter[$key]));
+ else
+ throw new TDataMapperException('unable_to_find_parameter', $key);
+ }
+ break;
+ default:
+ var_dump("todo for other parameter classes");
+ }
+ }
+*/
+}
+
+?> \ No newline at end of file