Using Unset($Model->Var) Calls Getter Function?

Hi,

I’m a bit confused right now.

i have the following code snippet: (the exits are for my debugging right now.)


			

$appId = 3;

if (isset($this->randomMedia))

   unset($this->randomMedia); //unset for new randomImage in while		

$this->setRandomMedia($appId); //<--- tells allready set

exit;



the setter for RandomMedia is telling me $this->randomMedia is allready set.

it seems like unset($this->randomMedia); is calling the getter getRandomMedia (wich is executing the setter cause of unset). Is it bug or is it a "feature"?

best regards

I’m not sure about your specific question, but I would do this instead:


$this->randomMedia = null;

Hi,

thanks for the reply.

To specify the question again ;)

Is it normal for Yii that calling unset($model->somevar); is calling the getter function of somevar?

My debug is showing: (new Model)


if(isset($model->somvar)){

CuLog::add(microtime().": true"); 

}else(

CuLog::add(microtime().": false"); 

}

unset($model->somevar);

//checkagain

if(isset($model->somvar)){

CuLog::add(microtime().": true"); 

}else(

CuLog::add(microtime().": false"); 

}

LogOutput:

false

true <- should be false?