执行数据库行DeleteAll,其中 1 个字段等于某项,而其他字段不等于某项
我正在努力做到这一点,我基本上想做一个数据库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]
I'm struggling with doing this, I want to basically do a database deleteAll where one field is equal to something and another field must NOT be equal to something.. its for deleting duplicate rows so I want to delete all but one row.. the way I tried below isn't working, I Would appreciate any advice:
$conditions = array (
"Prox.proxy" => $currentproxytocheck,
"AND" => array (
"NOT" => array (
"Prox.proxyid" => $currentproxyid
)
)
);
$this->Prox->deleteAll(array( 'conditions' => $conditions));
EDIT:
The printout of my $conditions array is:
Array
(
[Prox.proxy] => 62.58.179.2:80
[AND] => Array
(
[NOT] => Array
(
[Prox.proxyid] => 36829
)
)
)
Error from 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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
deleteAll
的语法与find< /code>
使用
你的数组可以像这样构建:
这是相同的事情,但更具可读性。
The syntax for
deleteAll
is different fromfind
Use
And your array could be built like so:
Which is the same thing, but more readable.