Yii model to array?

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

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

相关标签:
14条回答
  • 2020-12-08 20:21

    Use simply:

    $trips = Trips::model()->findAll();
    
    $trips_array = CJSON::decode(CJSON::encode($trips));
    

    Note: This is not good way but returns array

    0 讨论(0)
  • 2020-12-08 20:24

    i use $array = CJSON::decode(CJSON::encode($model)); to convert $model to $array.

    0 讨论(0)
提交回复
热议问题