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

Phalcon can not save model.

I can find my table in moel, and after updating when I save it.

there is an error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'username.tablename' doesn't exist

and why username.tablename? is should be "databasename.tablename" ?



5.2k
edited May '15
  • I find my table via findFirst

$user = \Model\User::findFirst([
"(email :email: OR id = :email:) AND pw = :password:'",
'bind' => array('email' => $email, 'password' => sha1($password))
]);

and is indeed get right data.

  • I update the instance

$user->setLoginTime(date("Y-m-d H:i:s"));
$user->setLoginIp($this->request->getClientAddress());

  • I save the instance.

if ($user->update() == false) {
$user->rollback("Cannot Update User Login info");
foreach ($user->getMessages() as $message) {
echo $this->flashSession->error($message);
}
}

I got the error

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'username.tablename' doesn't exist

so, I am confused that why I can't save the data, and also why is

username.tablename'

not

databasename.tablename'

?



43.9k

Strange indeed.