0

私はこれを行うのに苦労しています。基本的に、1つのフィールドが何かと等しく、別のフィールドが何かと等しくないデータベースのdeleteAllを実行したい..重複する行を削除するため、1行を除くすべてを削除したい..以下で試した方法は機能しません。アドバイスをいただければ幸いです。

 $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 に答える