Hello everyone!
I’m following the book and stuck in trying understand the actionAdmin in ProjectController.
It says:
public function actionAdmin()
{
$model=new Project('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Project']))
$model->attributes=$_GET['Project'];
$this->render('admin',array(
'model'=>$model,
));
}
My questions are:
- what does
$model=new Project('search');
means? Parameter ‘search’ is used for what in this particular situation?
What if we wrote
$model=new Project();
- Why should we do this
$model->unsetAttributes();
We know that Project extends TrackStarActiveRecord( and TrackStarActiveRecord extends CActiveRecord)
So new Project(‘search’) refers to __construct() of CActiveRecord.
With help of api documentation, it says:
public void __construct(string $scenario='insert')
inside __construct I see number of things that I’m not familiar with.
So I want to hear from you.
Cheers!