Yii model to array?

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

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

14条回答
  •  借酒劲吻你
    2020-12-08 20:18

    You can create collections CMap continue to work with her

    $collections = new CMap();
    foreach (YourModel::model()->findAll(['index' => 'id']) as $key => $row) {
       $collections->add($key,$row->attributes);
    }
    var_dump($collections ->toArray());
    

提交回复
热议问题