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

Call to undefined method Error::save()

Hi, I have this error when I try to save data with the model "Error", other models like "member" save fine, but this always return error. Someone to help? Error: Call to undefined method Error::save()

        if (!$member->save()) {

            foreach ($member->getMessages() as $message) {

                $error = new Error();
                $error->Message = $message->getMessage();
                $error->Controller = $this->dispatcher->getControllerName();
                $error->Action = $this->dispatcher->getActionName();

                $error->save();  // here is the error
            }

        } else {

            return json_encode($this->response);
            exit;
        }

Are You sure it's Phalcon Model?

See what

echo get_class($error);

would show.

Yes. it is a Phalcon model. the echo return the name of the model "Error"



1.7k

Replace

$error->save()

with

if (!$error->save()) {
    die(var_dump($error->getMessages()));
}

Replace

$error->save()

with

if (!$error->save()) {
  die(var_dump($error->getMessages()));
}

Dont think it'll work



1.7k

For debugging purposes

Replace

$error->save()

with

if (!$error->save()) {
 die(var_dump($error->getMessages()));
}

Dont think it'll work



8.4k

there is a predefined Error class in php 7

you may want to either rename your model or use a namespace

https://www.php.net/manual/en/class.error.php