Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.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
Mysql 停止重复后无法添加_Mysql_Codeigniter_Grocery Crud - Fatal编程技术网

Mysql 停止重复后无法添加

Mysql 停止重复后无法添加,mysql,codeigniter,grocery-crud,Mysql,Codeigniter,Grocery Crud,我一直试图阻止用户条目中的重复行,我得到了这项工作,但当我添加一个不存在的行时,它不允许我保存条目。它应该让我添加新的entrie。怎么了 模型功能 public function get_duplicaterow() { $query = $this->db->query('SELECT * FROM intervaloshorarios INNER JOIN citas ' . 'ON intervaloshorarios.idI

我一直试图阻止用户条目中的重复行,我得到了这项工作,但当我添加一个不存在的行时,它不允许我保存条目。它应该让我添加新的entrie。怎么了

模型功能

public function get_duplicaterow() {

        $query = $this->db->query('SELECT * FROM intervaloshorarios INNER JOIN citas '
                . 'ON intervaloshorarios.idIntervaloHorario = citas.idIntervaloHorario '
                . 'GROUP BY citas.cita, intervaloshorarios.idIntervaloHorario '
                . 'HAVING COUNT(*) >= 2');


        return $query->result();
    }
在主控制器中

 $crud->set_rules('intervaloHorario', 'Franja Horaria', '_callback_doublerow_check');
  public function doublerow_check() {

            $this->Fechacita_Model->get_duplicaterow();
 $q = $this->Fechacita_Model->get_duplicaterow();
        if ($count_row > 0) {
        //if count row return any row; that means you have already this email address in the database. so you must set false in this sense.
        return FALSE; // here I change TRUE to false.
    } else {
        // doesn't return any row means database doesn't have this email
        return TRUE; // And here false to TRUE
    }

        }
在控制器中

 $crud->set_rules('intervaloHorario', 'Franja Horaria', '_callback_doublerow_check');
  public function doublerow_check() {

            $this->Fechacita_Model->get_duplicaterow();
 $q = $this->Fechacita_Model->get_duplicaterow();
        if ($count_row > 0) {
        //if count row return any row; that means you have already this email address in the database. so you must set false in this sense.
        return FALSE; // here I change TRUE to false.
    } else {
        // doesn't return any row means database doesn't have this email
        return TRUE; // And here false to TRUE
    }

        }

doublerow\u check
函数不应该返回一些东西吗

更新

我猜你必须返回真或假。True将验证允许您的新条目的规则,false将意味着您的新条目不遵守设置的规则(或者可能是另一种方式?)。在本例中,如果查询未找到任何行,则通过验证。因此,我将返回类似于
从$q==0找到的行的内容。但是,当您要插入新值时,是否正在执行此检查?在这种情况下,即使只有一个条目已经存在,您也应该使该条目无效。

它不起作用,我将更新de QUOTE代码。我忘记了return语句,但它仍然不起作用…我认为返回查询的原始结果也没有多大意义,请检查我的更新。好的,我已经更改了这个,我将再次更新代码,我现在正在计算行数,但仍然不起作用