gpt4 book ai didi

mysql - CakePHP $this->模型->查询

转载 作者:行者123 更新时间:2023-11-30 01:37:56 25 4
gpt4 key购买 nike

我尝试运行以下代码,但仅当我在 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 中使用,<> 工作正常。不知道问题出在哪里。

最佳答案

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

关于mysql - CakePHP $this->模型->查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16602608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com