0

我正在为此苦苦挣扎,我想基本上做一个数据库 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]   
4

1 回答 1

6

语法deleteAll不同于find

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

采用

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

你的数组可以这样构建:

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

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

于 2010-08-07T21:26:25.170 回答