I am migrating from Codeigniter 3 to Codeigniter 4 and the next query is problematic to me.
In Codeigniter 3, the query was:
$this->db->query("UPDATE myTable SET data = '$data',
myData = IF ( ISNULL(myData), '$state', CONCAT('$state', '-', myData) )
WHERE id = '$id'");
I tried to change this with the next format:
$data = array(
'myData' => "IF( ISNULL(myData), " . $state. ", CONCAT(" . $state. ", '-', myData')")
);
However, the function updates the content of $myData like a string "IF( ISNULL(myData), " . stateOfExample. ", CONCAT(" . stateOfExample. ", '-', myData')".
I have looked into the CI4 documentation but I could not find the way to develop this query. I find the way to do that with the where() CI function, but I think is not the best way to do that.