我无法在 sql 查询中添加 OR 运算符

I can't add OR operator inside my sql query

我的代码如下所示:

$database->update($campaign_table, $data_nga_posti , array("AND" => ["codice_pod" => $data_nga_posti['codice_pod'],("codice_pdr" =>NULL) ]));

所以这是我的查询执行的时间:

UPDATE `field` SET `columnname` = 'data',`anothercm` = 'data',WHERE `codice_pod` = 'IT001E35563561' AND `codice_pdr` IS NULL

我希望我的查询看起来像这样。

UPDATE `field` SET `columnname` = 'data',`anothercm` = 'data',WHERE `codice_pod` = 'IT001E35563561' AND (`codice_pdr` IS NULL OR `codice_pdr` ="")

但我不知道如何将 OR(运算符) 放入此代码中。

试试这个:

array("AND" => ["codice_pod" => $data_nga_posti['codice_pod'],"OR" => ["codice_pdr" =>NULL,`codice_pdr` ="" ] ])

我以前从未使用过这个,也没有什么可以测试的,但是 the documentation 中发布的封闭示例是:

$database->has("account", [
    "AND" => [
        "OR" => [
            "user_name" => "foo",
            "email" => "foo@bar.com"
        ],
        "password" => "12345"
    ]
]);

所以我认为这对你有用:

$database->update($campaign_table, $data_nga_posti, [
    "AND" => [
        OR => [
            "codice_pdr" =>NULL, 
            "codice_pdr" => ""
        ],
        "codice_pod" => $data_nga_posti['codice_pod']
    ]
]);