Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.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 致命错误:调用未定义的方法CI_DB_mysql_driver::group_start()_Php_Codeigniter - Fatal编程技术网

Php 致命错误:调用未定义的方法CI_DB_mysql_driver::group_start()

Php 致命错误:调用未定义的方法CI_DB_mysql_driver::group_start(),php,codeigniter,Php,Codeigniter,我正在开发codeigniter php web应用程序。我有这样的错误: 致命错误:在第31行的C:\wamp\www\CI\u sock\application\models\customer\u m.php中调用未定义的方法CI\u DB\u mysql\u driver::group\u start() 如何解决这个问题。下面是我的PHP代码: foreach ($this->column_search as $item) // loop column {

我正在开发codeigniter php web应用程序。我有这样的错误:

致命错误:在第31行的C:\wamp\www\CI\u sock\application\models\customer\u m.php中调用未定义的方法CI\u DB\u mysql\u driver::group\u start()

如何解决这个问题。下面是我的
PHP
代码:

foreach ($this->column_search as $item) // loop column 
    {
        if($_POST['search']['value']) // if datatable send POST for search
        {

            if($i===0) // first loop
            {
                $this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND.
                $this->db->like($item, $_POST['search']['value']);
            }
            else
            {
                $this->db->or_like($item, $_POST['search']['value']);
            }

            if(count($this->column_search) - 1 == $i) //last loop
                $this->db->group_end(); //close bracket
        }
        $i++;
    }
共有31行
$this->db->group_start()像这样

请帮我解决这个问题。

试试这个方法

$this->db->group_start();
$this->db->or_group_start(); 
foreach ($this->column_search as $item) // loop column 
    {
        if($_POST['search']['value']) // if datatable send POST for search
        {
                    $this->db->or_like($item, $_POST['search']['value']);
        }
    }
   $this->db->or_group_end();
   $this->db->group_end();
注意:我现在无法选中“执行此代码”

请尝试这种方法

$this->db->group_start();
$this->db->or_group_start(); 
foreach ($this->column_search as $item) // loop column 
    {
        if($_POST['search']['value']) // if datatable send POST for search
        {
                    $this->db->or_like($item, $_POST['search']['value']);
        }
    }
   $this->db->or_group_end();
   $this->db->group_end();

注意:我现在无法选中“执行此代码”

我有此问题的解决方案,请将您的代码更改为以下内容:

if($_POST['search']['value']) // if datatable send POST for search
            {

                if($i===0) // first loop
                {
                    // $this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND.
                    $this->db->like($item, $_POST['search']['value']);
                }
                else
                {
                    $this->db->or_like($item, $_POST['search']['value']);
                }

                if(count($this->column_search) - 1 == $i); //last loop
                    // $this->db->group_end(); //close bracket


            }

我有此问题的解决方案,请将您的代码更改为:

if($_POST['search']['value']) // if datatable send POST for search
            {

                if($i===0) // first loop
                {
                    // $this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND.
                    $this->db->like($item, $_POST['search']['value']);
                }
                else
                {
                    $this->db->or_like($item, $_POST['search']['value']);
                }

                if(count($this->column_search) - 1 == $i); //last loop
                    // $this->db->group_end(); //close bracket


            }

可以尝试在foreach之前应用group_start(),在循环之后应用group_end吗?请使用代码。我不是codeigniter中的express。这取决于您想要如何对它们进行分组,也有或_group可分别用于分组或条件
>或_group_start()->where('b','b')->where('c','c')->group_end()
请为这些示例写下它。我想要完整的代码。你能试着在foreach之前应用group_start(),在循环之后应用group_end吗?请用代码剪切。我不是codeigniter中的express。这取决于您想要如何对它们进行分组,也有或_group可分别用于分组或条件
>或_group_start()->where('b','b')->where('c','c')->group_end()
请为这些示例写下它。我想要完整的代码。如果你评论$this->db->group_start();如果您注释$this->db->group_start(),则会产生错误的结果;它会产生错误的结果