Multiple updation query in Phql

Can any one give phql query for updating 2 columns in multiple rows in table



13.8k
edited 17d ago

You can do something like that:

$res = $this->db->execute("UPDATE media SET image_1 = ?, image_2 = ? WHERE usersId = ?",array($uploadDir1,$uploadDir2,$id));
    if (!$res) {
        $this->flash->error("Something went wrong...");
    } else {
        $this->flash->success("Image was updated successfully");
    }
edited 17d ago

updating multiple records at the same time

Then just change WHERE condition to whatever you need :)

But keep in mind that every UPDATE/INSERT/DELETE query in PHQL will be translated into SELECT statement + proper method call.

I think he's after batch updates... afaik there is no ready solution for that, so go for transactions

Then batch update with phql is not possible. Use raw sql.