$data = Test::model()->findByAttributes(array('id' => $id)); 

As I understand, all the attributes are stored in the $data->_attrib array, but the problem is that it is private and I cannot access it. Is it possible to pull out all the values ​​of the _attrib array, and even better to get an associative array of the form mas[attrib] = value; ?

  • ( new Test() )->attributes . Docs - Roman Grinyov
  • Happened! Do not tell me how now, to bring this into an associative array: [params] => a: 15: {s: 2: "id"; N; s: 10: "request_id"; s: 5: "90748"; s: 7: "version"; N; s: 4: "name"; s: 0: ""; s: 6: "series"; s: 1: "2"; s: 5: "modes"; a: 1 : {i: 0; s: 16: "Main";}. I thought it was JSON, but it turned out not. - PaCman
  • So what is this format? You write the code, and not someone else - then you know what kind of format you want to use it once ... - Roman Grinyov

1 answer 1

In the Documentation http://www.yiiframework.com/doc/api/1.1/CModel#getAttributes-detail

Example if ($ data) {$ data-> getAttributes (['name'])}