V
V
Vanik Khachatryan2018-05-20 13:18:48
Phalcon
Vanik Khachatryan, 2018-05-20 13:18:48

Why don't save() and create() work in Phalcon?

the specified functions do not work, they always return false.

$accounts = new Accounts();
        $accounts->login = $username;
        $accounts->password = $password;
        $accounts->steam_guard = $steam_guard;
        $accounts->worker_id = $worker_id;

        $this->response->setJsonContent(['good' => $accounts->save()])->send();

getMessages() returns an empty array.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Terekhin, 2018-05-20
@VaniXac

It cannot be so. Either the framework will throw an exception in case of problems with connecting to the database, or getMessages () contain information about the error.

$accounts = new Accounts;
        $accounts->login = 'test';
        $accounts->password = 'ABCDEF';
        $accounts->steam_guard = '0';
        $accounts->worker_id = '1';
        if ($accounts->save() === false) {
               $messages = $accounts->getMessages();
               foreach ($messages as $message) {
                            echo $message, "\n";
                }
        }

By the way, if the table has NotNull fields with a default value, and in the model this field suddenly turns out to be empty, then the ORM will return false when saved, but the record in the database will fall, because everything is ok for mysql.
The structure of the table in the studio

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question