1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
//mon cron commence toujours par éxécuter cette méthode, qui lui affecte le travail.
protected function setRequetes_id(){
$connex=new ConnexionToto();
$toto=$connex->pdo;
//mieux vaut figer les données temps d'abord
$temps=date("m:d:H:i:w");
$elem=explode(':',$temps);
$sql='SELECT distinct requete_id FROM `frequence`
WHERE month in ("any","'.$elem['0'].'")
and (
day in ("any","'.$elem['1'].'")
or cast("'.$elem['1'].'" as unsigned) BETWEEN cast( substring( day, 1, 2) as unsigned) AND cast( substring( day, 4, 2 ) as unsigned)
or day = "jour_sem" and (
jour_sem="'.$elem['4'].'"
or cast("'.$elem['4'].'" as unsigned) BETWEEN cast( substring( jour_sem, 1, 1) as unsigned) AND cast( substring(jour_sem, 3, 1 ) as unsigned)
)
)
and (
hour in ("any","'.$elem['2'].'")
or cast("'.$elem['2'].'" as unsigned) BETWEEN cast( substring( hour, 1, 2) as unsigned) AND cast( substring( hour, 4, 2 ) as unsigned)
)
/*mes minutes étaient gérées différemment des tiennes, tu complèteras*/
and now() between debut and fin;';
echo '<pre>'.$sql.'</pre>';
try{
$stmt=$toto->prepare($sql);
$stmt->execute();
while($result = $stmt->fetch(PDO::FETCH_ASSOC)){
array_push($this->requetes_id,$result);
}
}
catch(PDOException $e){
echo "<br/>\nErreur SQL cron <br/>\n";
echo $e->getMessage();
}
$connex->close();
} |
Partager