1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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");
}
}
*/
}
?>
|