【问题标题】:CakePHP $this->model->queryCakePHP $this->model->query
【发布时间】:2013-05-17 06:14:29
【问题描述】:

我正在尝试运行以下代码,并且仅当我在 where 子句中使用 not 条件时才会出错。我知道我应该使用 cake 的 save 方法,但由于某种原因,我必须使用 $this->model->query。

$this->Model->query("insert into students values ($department_id,$class_id) where depid <> $department_id and classid <> $class_id");

我收到如下错误:

SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where tagid <> 1 and contactid <> 32' at line 1 [CORE\cake\libs\model\datasources\dbo_source.php, line 681]


Query: insert into students values(3,2) where depid <> 3 and classid <> 2

我尝试输入 depid!=3 而不是 depid=3,但 CakePHP 没有任何效果,但是,如果我直接在 MySql 中使用 ,则效果很好。不知道问题出在哪里。

【问题讨论】:

    标签: mysql cakephp-1.3


    【解决方案1】:

    INSERT 表达式没有 WHERE 子句。 Read the documentation.

    【讨论】:

      猜你喜欢
      • 2014-05-04
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 2011-03-17
      • 2011-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多