Reputation: 29
When i run a query like this:
$this->User->query("DELETE FROM users WHERE deleted = 1 AND created <= '".$created."'");
How do i know if there's was an error running the query?
I want to send a message to the user if there was an error something like:
if(!$this->User->query("DELETE FROM users WHERE deleted = 1 AND created <= '".$created."'"))
$this->Session->setFlash('There was an error running this query');
This method always return 0, but the query is running without errors
Upvotes: 0
Views: 451
Reputation: 6066
You want to know if there is an error, or if any records were deleted?
You can use something like $this->User->deleteAll instead
$this->User->deleteAll(array(
'deleted' => 1
'created <=' => $created
));
It will return boolean True on success, false on failure.
Upvotes: 2