0
Hello, how are you? All right?
I’ll explain my situation and already show you what I have, come on:
So, I need to schedule the deletion of a data from SQL, I have a system that publishes polls, in this publication, I define a deletion DATE, I call expire, I have a class called Poll, that class that manages all information and collects relevant data from the polls.
My next step is to let this (deletion scheduling) work, but I have some rules for this, I don’t intend to use Mysql Events, I want to use PHP and Cronjob, the code I am TRYING to do is this:
public function sync()
{
$sql = "DELETE FROM tb_poll WHERE active = 1 AND date < expiredate";
$stmt = connection::prepare($sql);
$stmt->execute();
}
in the class builder, I call this function as follows:
switch ($_GET['exec'])
{
case 'dhgahjpJOPpHPhHvhKMoph':
$this->sync();
break;
//restante do código
So I access it like this: ?page=poll&exec=dhgahjpJOPpHPhHvhKMoph
That being said, the error I get from the browser is Error 500.
localhost is currently unable to respond to this request. HTTP ERROR 500
I have already tested DELETE only by informing the output of the active field (which is already preset as '1'), however, I was not successful.
Note: the tables are related and the fields defined for Default: 0
Check the error returned in the log file.
– MagicHat
The Cronjob is enabled?
– Heitor Scalabrini
I’m not generating any log for this, and I don’t have a working chronojob yet, because the part needed to be executed, is not ready. Complementing, I already discovered my error, as some fields in the Database are Foreign key, I needed to inform that the field was ON DELETE CASCADE, otherwise it would not work.
– rengaw