I want a quick and easy way to get a list of values from a table as an associative array, in wich the keys would be the ID of the table, and the value, any field of the database.
I mean, i want to do this with a one-liner:
$projects = [];
foreach (Projects::find(['columns' => ['id', 'name']])->toArray() as $key => $project)
{
$projects[$project['id']] = $project['name'];
}
But I can't find a practical way to do it, I also know CakePHP, and with cake you would do something like this:
$this->Projects->find('list');
(Having previously defined the key and value fields in the model)
Any suggestions? If it's not implemented, I think it would be a really cool feature to have :D