除了一些消息来源说查询生成器语句已准备好,另一些消息来源说它们已准备好但未绑定(bind),然后有些消息来源说它们已绑定(bind)等之外,我没有找到太多文档。如果有可靠的答案,我们将不胜感激。
此外,如果我想将表单数据传递到我存储在数据库中的数组中,应该如何修改以下代码?
$user_first = $this->input->post('user_first');
$data['user_first'] = $user_first;
//this above code works fine if I want to store each part of the form
//in the array individually
$data = array(
'user_first' => 'My title'
//How can I get 'user_first' to => $user_first?
);
$this->pdo->insert('users', $data);
谢谢。
最佳答案
几种方法
//adding name by name to an array
$data = array('user_first' => $this->input->post('user_first'));
adding the entire post array
//as u have the same "name" in the form than the array u are sending to the db insert method
$data = $this->input->post();
//in short $this->input->post() is $_POST array, but cleaned
//or getting the values from $_POST
$data = array('user_first' => $_POST['user_first']);
希望我的回答对你有帮助。
关于PHP CodeIgniter 框架 - 查询生成器是否算作prepare() 和bind_param() 以及如何将表单发布数据存储到查询生成器数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48403115/