3

My code look like this:

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

So this is when my query execute:

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

I want to my query look like this.

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

but I dont know how to put OR(operator ) inside this code.

peterh
  • 11,875
  • 18
  • 85
  • 108
Mr Alb
  • 291
  • 2
  • 4
  • 16

2 Answers2

3

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

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

So I think this would work for you:

$database->update($campaign_table, $data_nga_posti, [
    "AND" => [
        OR => [
            "codice_pdr" =>NULL, 
            "codice_pdr" => ""
        ],
        "codice_pod" => $data_nga_posti['codice_pod']
    ]
]);
GarethD
  • 68,045
  • 10
  • 83
  • 123
  • Yeah,this works for me,sure with some changes.So Thank you very much for your answers,its my first question and maybe im not very clear with my question,anyway the first is the first... Good Luck :) – Mr Alb Apr 17 '15 at 15:15
0

try this:

array("AND" => ["codice_pod" => $data_nga_posti['codice_pod'],"OR" => ["codice_pdr" =>NULL,`codice_pdr` ="" ] ])
mohsenJsh
  • 2,048
  • 3
  • 25
  • 49
  • 1
    How can you possibly now this will work? He hasn't even posted his `update()` method yet. – Daan Apr 17 '15 at 11:40