我正在努力做到这一点,我想基本上做一个数据库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]
发布于 2010-08-07 21:26:25
syntax for deleteAll
与find
不同
deleteAll(mixed $conditions, $cascade = true, $callbacks = false)
使用
$this->Prox->deleteAll($conditions);
你的数组可以这样构建:
$conditions = array (
"Prox.proxy" => $currentproxytocheck,
"Prox.proxyid <>" => $currentproxyid
);
这是相同的事情,但更具可读性。
https://stackoverflow.com/questions/3432084
复制相似问题