Error 500 with PHP 5.3

Hi there!

I just moved my Yii project from PHP 5.2 to a server with PHP 5.3 and now I get a 500 error:

Code:




$command->bindParam(":id", Yii::app()->user->contact_id, PDO::PARAM_STR);



If I change this line as followed, it does work as expected:




$command->bindParam(":id", Yii::app()->user->getState('contact_id'), PDO::PARAM_STR);



So i guess it has something to do with overloading with __get and __set.

Any comments on this?

Regards

ycast

bindParam() will bind the variable by reference to the placeholder. So if the value of the variable changes, the placeholder value will get updated, too. That’s useful if you e.g. want to perform the same query with different values in a loop. Since Yii::app()->user->contact_id is not a “real” variable, PHP can’t bind by reference here. PHP 5.3. seems to be more rigid on error reporting here.

My guess is, you don’t need that feature anyway and could use bindValue() instead.

bindValue() does work, thanks :)

I found out that the error is shown because of error_reporting level E_NOTICE (or E_ALL since it includes E_NOTICE since PHP 5.3).