Use {@link SqlMapGateway getSqlMapGateway()} property to obtain the gateway instance used for querying statements defined in the SqlMap configuration files. $conn = new TDbConnection($dsn,$dbuser,$dbpass); $manager = new TSqlMapManager($conn); $manager->configureXml('mydb-sqlmap.xml'); $sqlmap = $manager->getSqlMapGateway(); $result = $sqlmap->queryForObject('Products');
Since: 3.1
Inheritance: extends Prado\TComponent
Ejemplo n.º 1
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()
 {
     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;
 }
Ejemplo n.º 2
0
 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_unitest', 'prado_unitest', 'prado_unitest');
     }
     $conn->setActive(true);
     if ($sqlMapManager === null) {
         $sqlMapManager = new TSqlMapManager($conn);
         $sqlMapManager->configureXml(dirname(__FILE__) . '/DynamicParameterTestMap.xml');
     }
     return $sqlMapManager;
 }