mysql - Convert SQL UPDATE statement to php with if else condition (codeigniter)
I want to make php code with SQL Update Statement in Codeigniter.
If I execution code in Codeigniter, the data in database will be updated too.
I want to update one column (ID_STATUS) but with several condition.
The connection column '
ID_STATUS' with column '
lama' and '
My table name is "pelayanan".
ID_STATUS is PK from table "status".
ID_STATUS in table "pelayanan" is foreign key from table "status".
I tried with this query, but, It isn't if else condition yet.
condition 1 :
UPDATE `dbhpl`.`pelayanan` SET `pelayanan`.`ID_STATUS` = '1' WHERE `pelayanan`.`LAMA` <> `pelayanan`.`ESTIMASI`;
UPDATE `dbhpl`.`pelayanan` SET `pelayanan`.`ID_STATUS` = '2' WHERE `pelayanan`.`LAMA` = `pelayanan`.`ESTIMASI`;
That is the query on mysql. But I want to convert that query to php code (Codeigniter).
How come It will be?