php - Yii create a new attribute in the model doesn't work -
i need create new attribute in model , weird happening:
this code, works fine:
class person extends cactiverecord { public $test = "xxx"; public function getrandomtoken() { $temp = $this->test; homecoming $temp; }
this code, not:
class person extends cactiverecord { public $test = md5(uniqid(rand(), true)); public function getrandomtoken() { $temp = $this->test; homecoming $temp; }
why? blank page sec code, no errors.
i need utilize random token create view-page , i'm doing in way:
echo $model->getrandomtoken();
thank support!
if not want overwrite contructor can utilize this:
class person extends cactiverecord { public $test = null; public function getrandomtoken() { if ($this->test == null){ $this->test = md5(uniqid(rand(), true)); } $temp = $this->test; homecoming $temp; }
php yii cactiverecord
No comments:
Post a Comment