我尝试使用cakephp从表的某一行检索数据,我想从提取的行中获取值。
P.S。我试图跟随cakephp的find(),但没有得到任何东西,反而得到了错误。 Error`$ login_id = $ this-> AppAuth-> user(' id'); $ userSettings = $ this-> loadModel(" UserSettings");
$userSetting= $this->$userSettings->find('first', array(
'conditions' => array('UserSettings.user_id' => $login_id)));`
答案 0 :(得分:0)
$query = $internSettings->find('all', [
'conditions' => ['InternSettings.intern_id' => $login_id]
]);
$row = $query->first();
现在我可以检索一行,我怎么想访问行的值?
答案 1 :(得分:0)
$record = $internSettings->find('all', [ 'conditions' => ['InternSettings.intern_id' => $login_id]])->first();
这将返回$record
中的实体对象,您可以通过
echo $record->field_name;
或者您可以将其转换为数组,然后您可以访问
$recordArr=$record->toArray();
echo $recordArr['field_name'];