From 2570226fbac3e26b1e94896b50d1db4bc1aa3308 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 17 Dec 2006 22:20:50 +0000 Subject: Add TDataSourceConfig, TSqlMapConfig, TActiveRecordConfig --- framework/Data/SqlMap/TSqlMapManager.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'framework/Data/SqlMap/TSqlMapManager.php') diff --git a/framework/Data/SqlMap/TSqlMapManager.php b/framework/Data/SqlMap/TSqlMapManager.php index 32656bd5..37d50f5d 100644 --- a/framework/Data/SqlMap/TSqlMapManager.php +++ b/framework/Data/SqlMap/TSqlMapManager.php @@ -14,10 +14,12 @@ Prado::using('System.Data.SqlMap.TSqlMapGateway'); Prado::using('System.Data.SqlMap.DataMapper.TSqlMapException'); Prado::using('System.Data.SqlMap.DataMapper.TSqlMapTypeHandlerRegistry'); Prado::using('System.Data.SqlMap.DataMapper.TSqlMapCache'); -Prado::using('System.Data.SqlMap.DataMapper.*'); +Prado::using('System.Data.SqlMap.Configuration.TSqlMapStatement'); Prado::using('System.Data.SqlMap.Configuration.*'); +Prado::using('System.Data.SqlMap.DataMapper.*'); Prado::using('System.Data.SqlMap.Statements.*'); + /** * TSqlMapManager class holds the sqlmap configuation result maps, statements * parameter maps and a type handler factory. @@ -27,7 +29,8 @@ Prado::using('System.Data.SqlMap.Statements.*'); * * * $conn = new TDbConnection($dsn,$dbuser,$dbpass); - * $manager = new TSqlMapManager($conn, 'mydb-sqlmap.xml'); + * $manager = new TSqlMapManager($conn); + * $manager->configureXml('mydb-sqlmap.xml'); * $sqlmap = $manager->getSqlMapGateway(); * $result = $sqlmap->queryForObject('Products'); * @@ -46,9 +49,6 @@ class TSqlMapManager extends TComponent private $_cacheModels; private $_connection; - - private $_configFile; - private $_gateway; /** @@ -56,10 +56,9 @@ class TSqlMapManager extends TComponent * @param TDbConnection database connection * @param string configuration file. */ - public function __construct($connection=null,$configFile=null) + public function __construct($connection=null) { $this->_connection=$connection; - $this->_configFile=$configFile; $this->_mappedStatements=new TMap; $this->_resultMaps=new TMap; @@ -119,6 +118,16 @@ class TSqlMapManager extends TComponent return $this->_gateway; } + /** + * Loads and parses the SqlMap configuration file. + * @param string xml configuration file. + */ + public function configureXml($file) + { + $config = new TSqlMapXmlConfiguration($this); + $config->configure($file); + } + /** * Configures the current TSqlMapManager using the given xml configuration file * defined in {@link ConfigFile setConfigFile()}. @@ -126,8 +135,6 @@ class TSqlMapManager extends TComponent */ protected function createSqlMapGateway() { - $config = new TSqlMapXmlConfiguration($this); - $config->configure($this->getConfigFile()); return new TSqlMapGateway($this); } -- cgit v1.2.3