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

发布于 2024-09-13 17:18:03 字数 945 浏览 2 评论 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]   

I'm struggling with doing this, I want to basically do a database deleteAll where one field is equal to something and another field must NOT be equal to something.. its for deleting duplicate rows so I want to delete all but one row.. the way I tried below isn't working, I Would appreciate any advice:

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

$this->Prox->deleteAll(array( 'conditions' => $conditions)); 

EDIT:

The printout of my $conditions array is:

Array
(
    [Prox.proxy] => 62.58.179.2:80
    [AND] => Array
        (
            [NOT] => Array
                (
                    [Prox.proxyid] => 36829
                )

        )

)

Error from 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]   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转身泪倾城 2024-09-20 17:18:03

deleteAll 的语法与 find< /code>

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

使用

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

你的数组可以像这样构建:

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

这是相同的事情,但更具可读性。

The syntax for deleteAll is different from find

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

Use

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

And your array could be built like so:

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

Which is the same thing, but more readable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文