PHP CodeIgniter 框架 - 查询生成器是否算作prepare() 和bind_param() 以及如何将表单发布数据存储到查询生成器数组中?

标签 php mysql codeigniter

除了一些消息来源说查询生成器语句已准备好,另一些消息来源说它们已准备好但未绑定(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/

相关文章:

codeigniter - 当我使用 codeigniter 电子邮件类发送电子邮件时显示 html 源的电子邮件

php - Codeigniter - 1 分钟后删除一条记录

php - 如果表行有值则发回消息

php - 如何将json格式的相同值的数组插入到php mysql的列中

mysql - 同一张表的记录之间的日期差异

php - 上传多张带有描述的图片?

php - JMeter 在 WAMP 上运行内存为 400MB

php - 无法从表中获取完整值

php - 如何根据列值以树形结构显示数据

php - CURL php 代码返回 http_code=0 和来自服务器消息的空回复