SQL查询后,我已经进行下面的SQL语句,并已获得表中的相关行。Access数据在CakePHP中
SQL;
$user = $this->UserVerifications
->find()
->where(['code' => $hash])
->all();
它从'UserVerifications'表中获得'code'列等于'hash'值的行。这个位有效,见下面的输出。
debug($user);
\src\Controller\UsersController.php (line 57) object(Cake\ORM\ResultSet) {
'items' => [
(int) 0 => object(App\Model\Entity\UserVerification) {
'id' => (int) 23,
'code' => '4206e38996fae4028a26d43b24f68d32',
'date_created' => object(Cake\I18n\FrozenTime) {
'time' => '2016-11-21T18:48:45+00:00',
'timezone' => 'UTC',
'fixedNowTime' => false
},
'[new]' => false,
'[accessible]' => [
'*' => true
],
'[dirty]' => [],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'UserVerifications'
}
]
}
根据CakePHP的网站,或者至少我读的方式,我应该能够通过执行以下操作来访问值ID;
echo $user->id;
通知(8):未定义的属性:蛋糕\ ORM \的ResultSet :: $ ID [APP /控制器\ UsersController.php 58行]
我失去了一些东西简单?
正是我需要的,谢谢! – ChrisBull