Yii model to array?

前端 未结 14 2012
南笙
南笙 2020-12-08 19:32

How can I convert the result of Trips::model()->findAll() to an array?

14条回答
  •  甜味超标
    2020-12-08 20:19

    Assuming from your question that you want all the attributes, a more compact solution to give you all attributes hashed by id, you can use CActiveRecord's 'attributes' pseudoproperty as follows:

    CHtml::listData(Trips::model()->findAll(), 'id', 'attributes')
    

提交回复
热议问题