Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TPreparedStatementFactory class file.
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TPreparedStatementFactory.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Data.SqlMap.Statements
11
 */
12
 
13
/**
14
 * TPreparedStatementFactory class.
15
 *
16
 * @author Wei Zhuo <weizho[at]gmail[dot]com>
17
 * @version $Id: TPreparedStatementFactory.php 2541 2008-10-21 15:05:13Z qiang.xue $
18
 * @package System.Data.SqlMap.Statements
19
 * @since 3.1
20
 */
21
class TPreparedStatementFactory
22
{
23
	private $_statement;
24
	private $_preparedStatement;
25
	private $_parameterPrefix = 'param';
26
	private $_commandText;
27
 
28
	public function __construct($statement, $sqlString)
29
	{
30
		$this->_statement = $statement;
31
		$this->_commandText = $sqlString;
32
	}
33
 
34
	public function prepare()
35
	{
36
		$this->_preparedStatement = new TPreparedStatement();
37
		$this->_preparedStatement->setPreparedSql($this->_commandText);
38
		if(!is_null($this->_statement->parameterMap()))
39
			$this->createParametersForTextCommand();
40
		return $this->_preparedStatement;
41
	}
42
 
43
	protected function createParametersForTextCommand()
44
	{
45
		foreach($this->_statement->ParameterMap()->getProperties() as $prop)
46
			$this->_preparedStatement->getParameterNames()->add($prop->getProperty());
47
	}
48
}
49