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

update

this is my query

  $phql = $this->modelsManager->executeQuery("UPDATE Videos SET viewed = (viewed + '".$viewsvideo."') WHERE id = :id:",
 array('id' => $id));

I could not write on ORM -> (viewed + '".$viewsvideo."')

how i can write this query on ORM or Query Builder?

On ORM you operate on objects. So firstly you have to select Videos, then update it.



4.7k
Accepted
answer
edited Feb '16
// It is not with Models namespace?
$video = Models\Videos::findFirst((int)$id);
/* $video = Models\Videos::findFirst([
    'conditions' => 'id={id:int}',
    'bind' => ['id' => $id]
]);*/
if ($video) {
    $video->viewed = $video->viewed + $viewsvideo;
    $video->save();
}

Maybe...

// It is not with Models namespace?
$video = Models\Videos::findFirst((int)$id);
/* $video = Models\Videos::findFirst([
  'conditions' => 'id={id:int}',
  'bind' => ['id' => $id]
]);*/
if ($video) {
  $video->viewed = $video->viewed + $viewsvideo;
  $video->save();
}

Maybe...

It works