Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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_Joomla - Fatal编程技术网

Php 将数组数组保存到数据库

Php 将数组数组保存到数据库,php,joomla,Php,Joomla,经过大量的搜索和失败后尝试。。我把这个问题贴在这里 实际查询[here][1]完成一半后,我无法将生成的数组数组保存到数据库中 最初我有一个输入数组,现在我的save函数看起来像这样 function store() { foreach($post['cats'] as $cat) { $query = 'insert into #__joomd_item_cat values('.$cat.', '.$row->id.')'; $thi

经过大量的搜索和失败后尝试。。我把这个问题贴在这里

实际查询[here][1]完成一半后,我无法将生成的数组数组保存到数据库中

最初我有一个输入数组,现在我的save函数看起来像这样

function store()
{
        foreach($post['cats'] as $cat)  {

        $query = 'insert into #__joomd_item_cat values('.$cat.', '.$row->id.')';
        $this->_db->setQuery( $query );

        if(!$this->_db->query())    {
            $obj->error = $this->_db->getErrorMsg();
            return $obj;
        }

    }
}
现在,我如何修改它以将我的数组数组放入数据库中

此函数由序列化方法触发。。因此,请重新检查您的答案和评论

function save(task) {
var data = $jd("form[name='<?php echo $array['editform']; ?>']").serializeArray();
    $jd.ajax({
          url: "<?php echo $url; ?>",
          type: "POST",
          dataType:"json",
          data: data,
          beforeSend: function()    {
            $jd(".poploadingbox").show();
          },
          complete: function()  {
            $jd(".poploadingbox").hide();
          },
          success: function(res)    {

            savesuccess(res);

          },
          error: function(jqXHR, textStatus, errorThrown)   {
            alert(textStatus);                 
          }
    }); 

你可以在检索时使用它,然后在检索时使用它。

你可以在检索时使用它。

简单的方法是序列化(请参见
serialize()
)你的数组并保存它,但它限制了你操作数据库中数据的能力。我能想到的就是使用函数serialize(),它可以像type:serialize($\u POST)一样使用;在ajax中有发送函数,但检索仍不清楚。。为了保存它们,我仍然需要一个数组,这让我很困惑。。简单的方法是序列化(请参见
serialize()
)数组并保存它,但它限制了您操作数据库中数据的能力;在ajax中有发送函数,但检索仍不清楚。。为了保存它们,我仍然需要一个数组,这让我很困惑。。作为一名基础知识的学习者,我能想到的就是使用函数serialize(),它可以像
type:serialize($\u POST)那样使用在ajax中的发送函数中,但检索仍然不清楚。。为了保存它们,我仍然需要一个数组,这让我很困惑。对不起,事情已经序列化了,现在你想让我如何继续..作为一个基础知识的学习者,我能想到的就是使用函数serialize(),它可以像
type:serialize($\u POST)那样使用在ajax中的发送函数中,但检索仍然不清楚。。为了保存它们,我仍然需要一个数组,这让我很困惑。对不起,这些东西已经序列化了,现在您希望我如何继续。。
  [1]: http://stackoverflow.com/questions/11583375/add-input-fields-dynamically-but-fields-are-generated-by-external-php-functions/11583597#11583597