如何在 cakephp 3 中使用 find all 获取关联数组形式的数据?

How to get data as associative array using find all in cakephp 3 ?

我有一个 table 呼叫用户,我试过下面的代码

$query = $this->Users->find('all',['conditions' => ['users.id' => 1]]);
$data = $query->toArray();

foreach ($data as $key => $value) {
          echo $value;
}

我得到了类似

的输出
{ "id": 1, "username": "admin", "image": "", "created": "2016-05-11T06:52:59+0000" } 

我需要

这样的数组
["0": 1, "1": "admin", "2": "", "3": "2016-05-11T06:52:59+0000"]

只需使用hydrate

$query->hydrate(false);
$data = $query->toArray();

那么你将得到一个关联数组而不是一个对象

那么如果你真的想要一个索引数组,你可以简单地做

foreach ($data as $key => $value) {
    debug(array_values($value));
}