Prado\Data\TDbConnection::setActive PHP Method

setActive() public method

Open or close the DB connection.
public setActive ( $value )
    public function setActive($value)
    {
        $value = TPropertyValue::ensureBoolean($value);
        if ($value !== $this->_active) {
            if ($value) {
                $this->open();
            } else {
                $this->close();
            }
        }
    }

Usage Example

 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;
 }