Yii model to array?

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

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

14条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 20:21

    Don't used CHtml::listData for this. It has to be used for other purposes. There is an index property of CDbCriteria which is suitable for you requirement.

    //1st option
    Trips::model()->findAll(array('index'=>'trip_id'));
    
    //2nd option
    $c = new CDbCriteria();
    $c->index = 'trip_id';
    Trips::model()->findAll($c);
    

提交回复
热议问题