We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multiple updation query in Phql

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



59.9k
edited Feb '17

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 Feb '17

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.