Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.3k
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...

```php // 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