Ric*_*ick 0 mysql cakephp delete-row mysql-error-1054
我正在努力做到这一点,我想基本上做一个数据库deleteAll,其中一个字段等于某个东西,另一个字段必须不等于某个东西..它用于删除重复的行,所以我想删除除一行之外的所有行...我在下面尝试的方式不起作用,我将不胜感激任何建议:
$conditions = array (
"Prox.proxy" => $currentproxytocheck,
"AND" => array (
"NOT" => array (
"Prox.proxyid" => $currentproxyid
)
)
);
$this->Prox->deleteAll(array( 'conditions' => $conditions));
Run Code Online (Sandbox Code Playgroud)
编辑:
我的$ conditions数组的打印输出是:
Array
(
[Prox.proxy] => 62.58.179.2:80
[AND] => Array
(
[NOT] => Array
(
[Prox.proxyid] => 36829
)
)
)
Run Code Online (Sandbox Code Playgroud)
来自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]
Run Code Online (Sandbox Code Playgroud)
该语法deleteAll
是不同find
deleteAll(mixed $conditions, $cascade = true, $callbacks = false)
Run Code Online (Sandbox Code Playgroud)
使用
$this->Prox->deleteAll($conditions);
Run Code Online (Sandbox Code Playgroud)
你的数组可以像这样构建:
$conditions = array (
"Prox.proxy" => $currentproxytocheck,
"Prox.proxyid <>" => $currentproxyid
);
Run Code Online (Sandbox Code Playgroud)
这是一回事,但更具可读性.