PHP - Yii - dynamic properties CActiveRecord -


i have class person have properties {property}_{countrycode}. class can have 20 properties , each property country code. 20x3 = 60 properties defined in class. each language need define them manually in class.

class person extends cactiverecord {      public $name_sk;     public $name_cz;          public $name_de;      public static function model($classname = __class__)     {         return parent::model($classname);     }      function tablename() {         return 'person';     }  } 

question: how generate/define these properties dynamically in class?

example:

public function __construct() {     $langs = array('sk', 'cz', 'de');     $properties = array('name', 'surname', 'age');     foreach($langs $lang) {         foreach ($properties $k => $value) {             $this->{$value. "_". $lang} = null;         }     } } 

in yii 1.x can't. if override cactiverecord._get() extending it.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

javascript - Bootstrap Popover: iOS Safari strange behaviour -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -