【发布时间】: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