Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用函数序列化并将数据数组插入数据库?_Php_Codeigniter - Fatal编程技术网

Php 使用函数序列化并将数据数组插入数据库?

Php 使用函数序列化并将数据数组插入数据库?,php,codeigniter,Php,Codeigniter,如何在数据库中插入具有函数的数据数组 请给我举个简单的例子?简单: $sSerialized = serialize($sData); INSERT INTO table SET field = ".myqsl_real_escape_string($sSerialized); 不过,我不建议将序列化数据存储到数据库中 对于特定于codeigniter的设置,我认为您可以看到它就像 控制器: function foo() { if( ! empty($_POST)) {

如何在数据库中插入具有函数的数据数组

请给我举个简单的例子?

简单:

$sSerialized = serialize($sData);
INSERT INTO table SET field = ".myqsl_real_escape_string($sSerialized);
不过,我不建议将序列化数据存储到数据库中

对于特定于codeigniter的设置,我认为您可以看到它就像

控制器:

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
    }
}