数据库行DeleteAll,其中1个字段等于某个东西而其他字段不等于某个东西

时间:2010-08-07 21:22:59

标签: 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)); 

编辑:

我的$ 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]   

1 个答案:

答案 0 :(得分:6)

syntax for deleteAllfind

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

使用

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

您的阵列可以这样构建:

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

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