我想知道是否有另一种更“像 cakephp 一样”的方式将 user_id 插入到同一个表上的多个插入中。我做什么的例子:
$user_id = $this->Auth->user('id');
if ($this->request->is('post')) {
foreach ($this->request->data['Post'] as $key => $value) {
if (is_int($key)) {
$this->request->data['Post'][$key]['user_id'] = $user_id;
}
unset($key);
unset($value);
}
debug($this->data['Post']);
die();
$this->Post->saveAll($this->data['Post']);
}
出于安全原因,我不使用输入隐藏值 user_id。谢谢你的帮助 !