How to use model()->getAttributes()?


(Tq0fqeu) #1

How to use model()->getAttributes()?

I do like this




//User table is not null, but $names is null

$names = User::model()->getAttributes('name'); 



pls give me a example


(Maurizio Domba Cerin) #2

If you check the documentation at http://www.yiiframework.com/doc/api/CModel#getAttributes-detail

will see that you need to pass an array

so use something like


$names = User::model()->getAttributes(array('name'));