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.

Partial DB update

How can i update only one column in my database ?

Example 1 ( Works But all other columns go blank ) :

$views = new Articles;
    $views->_     = $article->_;
    $views->views = ($views->views + 1);
$views->save();

Example 2 ( Just dosen't work ) :

$views = new Articles;
    $views->_     = $article->_;
    $views->views = ($views->views + 1);
$views->update();


14.4k
Accepted
answer

You can use the database component: https://docs.phalconphp.com/en/latest/reference/db.html#inserting-updating-deleting-rows

thanks , but i found the solution :

$article  = Articles::findFirstByUrlrequest($this->dispatcher->getParam(0));

        $article->views = ($article->views + 1);
        $article->update();