The default connection can be set as follows: TActiveRecordManager::getInstance()->setDbConnection($conn); All new active record created after setting the {@link DbConnection setDbConnection()} will use that connection unless the custom ActiveRecord class overrides the ActiveRecord::getDbConnection(). Set the {@link setCache Cache} property to an ICache object to allow the active record gateway to cache the table meta data information.
Since: 3.1
Inheritance: extends Prado\TComponent
Example #1
0
 function __construct()
 {
     if (!class_exists("TActiveRecordManager", false)) {
         throw new Exception("You need to enable the ActiveRecord module in your application configuration file.");
     }
     $ar_manager = TActiveRecordManager::getInstance();
     $_conn = $ar_manager->getDbConnection();
     $_conn->Active = true;
     $this->_dbMetaData = TDbMetaData::getInstance($_conn);
 }
Example #2
0
 /**
  * @return TActiveRecordManager
  */
 public function getManager()
 {
     if ($this->_manager === null) {
         $this->_manager = Prado::createComponent($this->getManagerClass());
     }
     return TActiveRecordManager::getInstance($this->_manager);
 }
Example #3
0
 /**
  * @return TActiveRecordGateway record table gateway.
  */
 public function getRecordGateway()
 {
     return TActiveRecordManager::getInstance()->getRecordGateway();
 }