Exemplo n.º 1
0
 /**
  * Returns the database connection used by active record.
  * By default, the "db" application component is used as the database connection.
  * You may override this method if you want to use a different database connection.
  * @return CDbConnection the database connection used by active record.
  * 
  * @TODO Get default db connection if theres none set
  * 
  */
 public function getDbConnection()
 {
     if (self::$db !== null) {
         return self::$db;
     } else {
         self::$db = Prado::getApplication()->getModule($this->getConnectionId())->getDbConnection();
         if (self::$db instanceof TDbConnection) {
             self::$db->setActive(true);
             return self::$db;
         } else {
             throw new TDbException('ActiveRecord requires a db connection.');
         }
     }
 }