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.

Fatal error while updating database records

Hi All,

I am trying to update each record inside database this way

    $allUsers = Users::find([
         'columns'   => 'user_name'
     foreach ($allUsers as $user){
         $this->tokenHash = $this->generateToken();
         $this->token = $this->userName.'|'.$this->tokenHash;
             'token'         => $this->token,
             'token_hash'    => $this->tokenHash

But, a fatal error happens when trying to update the records:

Fatal error: Uncaught Error: Call to undefined method Phalcon\Mvc\Model\Row::save()

Any ideas ?

edited Feb '18

You are only querying one column, user_name, so the ORM does not build a full Users model instance, only a Row.

Just issue $allUsers = Users::find();

Thank alot, it's working fine now.