Пример #1
0
 /**
  * Contruct of this class.
  * 
  * @param string $scenario object access scenario
  * @param mixed  $object   modifying object instance or id
  */
 public function __construct($scenario = self::SCENARIO_CREATE, $object = null)
 {
     if (isset($object)) {
         $this->setObject($object);
     }
     parent::__construct($scenario);
 }
 /**
  * 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.
  */
 public function getDbConnection()
 {
     if (self::$db !== null) {
         return self::$db;
     } else {
         self::$db = Yii::app()->getDb();
         if (self::$db instanceof CDbConnection) {
             return self::$db;
         } else {
             $message = Yii::t('packages', 'Transactional form model requires a "db" CDbConnection application component.');
             throw new CDbException($message);
         }
     }
 }