我使用Post::model()->getAttributes()想得到数组。可是取到的数组是空的,数组结构是有的,但是没有值。是我用的方法不对吗?
我使用Post::model()->getAttributes()想得到数组。可是取到的数组是空的,数组结构是有的,但是没有值。是我用的方法不对吗?
是的,你的使用方法错了。
你看API的描述:
getAttributes() Returns all column attribute values.
所以你在使用 getAttributes() 之前,要先把数据提出来。
Example:
$model = POST::model()->findByPk(1);
CVarDumper::dump($model->getAttributes(), 10, true);
原来如此,我说呢,谢了。