/** * Initialize an sqlMap */ protected function initSqlMap() { $manager = new TSqlMapManager($this->config->getConnection()); $manager->configureXml($this->config->getSqlMapConfigFile()); $this->sqlmap = $manager->getSqlMapGateway(); $manager->TypeHandlers->registerTypeHandler(new TDateTimeHandler()); }
function test() { $manager = new TSqlMapManager(); try { $manager->configureXml(dirname(__FILE__) . '/sqlmap.xml'); $this->fail(); } catch (TSqlMapConfigurationException $e) { $expect = 'Invalid property \'parametrClass\' for class \'TSqlMapStatement\' for tag \'<statement id="findNotVisitedWatchedTopicList"'; $this->assertEquals(strpos($e->getMessage(), $expect), 0); } }
/** * Create and configure the data mapper using sqlmap configuration file. * Or if cache is enabled and manager already cached load from cache. * If cache is enabled, the data mapper instance is cached. * * @return TSqlMapManager SqlMap manager instance * @since 3.1.7 */ public function getSqlMapManager() { Prado::using('System.Data.SqlMap.TSqlMapManager'); if (($manager = $this->loadCachedSqlMapManager()) === null) { $manager = new TSqlMapManager($this->getDbConnection()); if (strlen($file = $this->getConfigFile()) > 0) { $manager->configureXml($file); $this->cacheSqlMapManager($manager); } } elseif ($this->getConnectionID() !== '') { $manager->setDbConnection($this->getDbConnection()); } return $manager; }
protected function getMysqlSqlMapManager() { static $conn; static $sqlMapManager; if (Prado::getApplication() === null) { Prado::setApplication(new TApplication(dirname(__FILE__) . '/app')); } if ($conn === null) { $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest'); } $conn->setActive(true); if ($sqlMapManager === null) { $sqlMapManager = new TSqlMapManager($conn); $sqlMapManager->configureXml(dirname(__FILE__) . '/DynamicParameterTestMap.xml'); } return $sqlMapManager; }