gpt4 book ai didi

mysql - 执行数据库行 DeleteAll,其中 1 个字段等于某物而其他字段不等于某物

转载 作者:行者123 更新时间:2023-12-01 00:33:06 24 4
gpt4 key购买 nike

我正在努力做这件事,我想基本上做一个数据库 deleteAll ,其中一个字段等于某物而另一个字段不能等于某物..它用于删除重复行所以我想删除除一个以外的所有行行..我在下面尝试的方法不起作用,我将不胜感激任何建议:

 $conditions = array (
"Prox.proxy" => $currentproxytocheck,
"AND" => array (
"NOT" => array (
"Prox.proxyid" => $currentproxyid
)
)
);

$this->Prox->deleteAll(array( 'conditions' => $conditions));

编辑:

我的 $conditions 数组的打印输出是:

Array
(
[Prox.proxy] => 62.58.179.2:80
[AND] => Array
(
[NOT] => Array
(
[Prox.proxyid] => 36829
)

)

)

来自 CAkephp 的错误:

Notice (8): Array to string conversion [CORE/cake/libs/model/datasources/dbo_source.php, line 2193]
Warning (512): SQL Error: 1054: Unknown column 'conditions' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 673]

最佳答案

syntax for deleteAll不同于find

deleteAll(mixed $conditions, $cascade = true, $callbacks = false)

使用

$this->Prox->deleteAll($conditions); 

你的数组可以这样构建:

$conditions = array (
"Prox.proxy" => $currentproxytocheck,
"Prox.proxyid <>" => $currentproxyid
);

这是一回事,但更具可读性。

关于mysql - 执行数据库行 DeleteAll,其中 1 个字段等于某物而其他字段不等于某物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3432084/

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