【发布时间】:2016-11-21 20:33:51
【问题描述】:
我已经执行了下面的 sql 语句,它已经从表中获取了相关的行。
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):未定义属性:Cake\ORM\ResultSet::$id [APP/Controller\UsersController.php, line 58]
我错过了一些简单的东西吗?
【问题讨论】: