如何在数据库中插入带有函数serialize的数据数组<input name='hello[]'>
?
答案 0 :(得分:0)
简单:
$sSerialized = serialize($sData);
INSERT INTO table SET field = ".myqsl_real_escape_string($sSerialized);
我不建议将序列化数据存储到您的数据库中。
对于codeigniter特定设置,我认为您可以看到http://codeigniter.com/user_guide/database/queries.html
答案 1 :(得分:0)
它就像......
控制器:
function foo()
{
if( ! empty($_POST))
{
$hello = serialize($_POST['hello']);
// You can do your database abstraction here, but is better to have these in your model
// Btw, by using CI AR, all values are escaped automatically producing safer queries.
$this->db->insert('some_table', array('hello' => $hello));
}
else
{
// do something
}
}