I cannot add an OR statement to my SQL query

Hey guys (this is my first question here). I have problems today. So I need some tips. My code is as follows:

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

So this is when my request is executed:

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

I want my query to look like this.

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

but I don’t know how to put an OR (operator) inside this code.

Many thanks!

+4
source share
2 answers

I have never used this before, and I have nothing to test, but the attached example is posted in the documentation :

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

So, I think this will work for you:

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

try the following:

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

All Articles