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

increment a field in query builder

Does the query class support incrementing a field like this?

$query = new Query("UPDATE MyList SET orderNumber = orderNumber + 1 WHERE orderNumber >= ?0 AND listId = ?1",$di);
$query->execute(array($moveTo,$myList->id));
edited Mar '14

Yes, run it like this:

$query = new Query("UPDATE MyList SET orderNumber = orderNumber + 1 WHERE orderNumber >= ?0 AND listId = ?1",$di);

$query->execute(array(
    0 => $moveTo,
    1 => $myList->id
    ));


9.2k

Why would adding the deafult array keys make a difference? Have you actually tried it?