Implementation of using AR to directly output one-dimensional array in A Bei job / Yii

I haven"t given an AR assignment for a long time. Today we"ll take a look at my needs.

there is a datasheet, user (id, username and created_at, with a total of 4 records. This is required for the job. Use AR to achieve the following results:

An one-dimensional array whose key is user"s id, array and value"s user"s username, is similar to the following result

[
    1=>"abei",
    2=>"abei2017",
    11=>"abei2018"
]

remember, only use AR, without resorting to other class libraries, such as Helper::map

Mar.28,2021

php built-in array: array_column ()


yii's built-in indexBy and column methods are used to implement the requirements in the problem.

  https://nai8.me/article/detai.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bd3f94-30eb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bd3f94-30eb8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?