开发者

Return values by Yii db

开发者 https://www.devze.com 2023-03-09 22:34 出处:网络
I have a following return value from Yii framework query, using the methods and classes built in Yii:

I have a following return value from Yii framework query, using the methods and classes built in Yii:

Array
(
    [0] => Array
        (
            [id] => 1
            [title] => Developer
        )

    [1] => Array
        (
            [id] => 2
            [title] => Tester
        )

)

I would开发者_JAVA技巧 like to (using nothing but Yii), rearange this like:

Array
(
    [1] => Developer
    [2] => Tester

)

Meaning, I will not group the results in a specific index of the array, and I will enlist them all in one array, AND my key/indexes will represent the value of ID field from my table, and value of those keys will be values from my "role" field from my table.

Is this possible and how?


You can use the following method, defined here:

CHtml::listData($yourArray, 'id', 'title');

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号