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

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();


37.4k
Accepted
answer

You can use the database component: https://docs.phalcon.io/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();