<?php

class RegActiveRecord extends CActiveRecord
{
	
	private static $reg_db = null;
	
	protected static function getRegDbConnection()
	{
		if (self::$reg_db !== null)
			return self::$reg_db;
			else
			{
				self::$reg_db = Yii::app()->registration_db;
				if (self::$reg_db instanceof CDbConnection)
				{
					self::$reg_db->setActive(true);
					return self::$reg_db;
				}
				else
					throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));
			}
	}	

	public function getDbConnection()
	{
		return self::getRegDbConnection();
	}  
}
