Hey guys,
I'm trying to update my table with save() or update() but something is wrong. Everytime that I send a post request with the new information that I want to update in my database, a JSON response is sent back to my brownser but this JSON response should just be sent when the update is sucessful and on my case nothing is changing on my database. Why save() is returning true? *My table has a primary key
Here is my code:
if ($this->request->isPost()) {
$jsonParsed = $this->request->getJsonRawBody();
$this->view->disable();
$users->user_id = $auth["user_id"];
$users->user_username = $jsonParsed->username;
if ( $users->save() == false ) {
foreach ($users->getMessages() as $message) {
echo $message->getMessage();
}
} else {
$array = array("resposta" => "ok");
$response = new \Phalcon\Http\Response();
$response->setHeader("Content-Type", "application/json");
$response->setContent(json_encode($array));
$response->send();
}
}