Hi,
I've run into a strange behavior when I tried to execute an update query with PHQL within an action called by AJAX.
Here is my action:
public function removeAction($id = null){
//Check if accessed via Ajax
$request = new \Phalcon\Http\Request();
if (!$request->isAjax()) {
//ERROR if try to reach via URL
$this->ajaxError();
} else {
//Disable view for Ajax
$this->view->disable();
if($id != null){
/* Update messages */
$q = "UPDATE [\Main\Models\Messages] AS messages SET messages.sender_deleted = IF(messages.sender_id = :sender_id:,:sender_deleted:,messages.sender_deleted), messages.receiver_deleted = IF(messages.receiver_id = :receiver_id:,:receiver_deleted:,messages.receiver_deleted) WHERE messages.conversation_id = :conv:";
$result = $this->modelsManager->executeQuery($q,array(
'sender_deleted' => 1,
'receiver_deleted' => 1,
'conv' => $id,
'sender_id' => $this->id,
'receiver_id' => $this->id
));
/* If successful update */
if($result->success() == true){
$error = 0;
} else {
$error = 1;
}
} else {
$error = 1;
}
echo json_encode($error);
}
}
Everything runs well until execution, then it stops and sends nothing back to JS, neither 0 nor 1.
The query itself is working, I can execute it in phpmyadmin, does what it has to. I also use IF statement with PHQL in other UPDATE query and it works well there. Binded parameters are also good, I've checked them.
I can var_dump $q
or anything else before execution, but nothing can be dumped after it. While no error messages are displayed, I have no idea what's the problem.
What may cause this behavior? How can I find out the problem?
I'm using Phalcon 2.