I am modifying existing functional code that relied on CActiveRecord. I am now connecting to sybase, which has no schema driver, so I am rewriting with CModel instead of CActiveRecord. My problem may be that I don't understand this general OOP concept?
Original: MyModelController.php
MyModel::model()->scenario='case1';
referring to ::model()
no longer works...because I believe this method only works when the base class is CActiveRecord.
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return ClientProg the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
How can I set the scenario attribute for MyModel now that it is based off of CModel, in the same fashion as I did when the base class was CActiveRecord?
When you call model(), it is internaly creating an instance for you the first time, and then refering to this cached object.
if your method its static then do not rely on properties on the instantiated version, you'll get headaches later on.
Check if a static property serve your needs, or pass the scenario as a parameter to your static calls.
anyway, static its evil, so avoid it if you can.