gpt4 book ai didi

PHP CodeIgniter Framework - Query Builder 是否算作 prepare() 和 bind_param() 以及如何将表单发布数据存储到 Query Builder 数组中?

转载 作者:行者123 更新时间:2023-11-29 02:12:22 25 4
gpt4 key购买 nike

除了一些消息来源说 Query Builder 语句已准备好,其他人说它们但未绑定(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 Framework - Query Builder 是否算作 prepare() 和 bind_param() 以及如何将表单发布数据存储到 Query Builder 数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48403115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com