PHP Classes

File: examples.php

Recommend this page to a friend!
  Classes of Oliver Leuyim Angel   PHP Cron Admin   examples.php   Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: 3 examples one to use db and other without db
Class: PHP Cron Admin
Schedule jobs stored in files and MySQL
Author: By
Last change: correct the error in the 3th example
Date: 10 years ago
Size: 1,863 bytes
 

Contents

Class file image Download
<?php

//EXAMPLE without data base.

require_once('class.cron.php');
$crontab=new crontab("/cron/", "filename", 'a'); //if u want to delete the old pass the 'w' parameter instead of 'a'
$crontab->setDateParams($min, $hour, $day, $month, "*"); //min , hour , day , month , dayofweek
$crontab->setCommand("curl http://somedomain.com/index.php?mod=sendcron");
$crontab->savetodb();
$crontab->saveCronFile();
$crontab->addToCrontab();
$crontab->destroyFilePoint(); // OPTIONAL


/********************************************************************************************/

//ANOTHER EXAMPLE using connection to db


require_once('class.cron.php');
$crontab=new crontab("/cron/", "filename", 'w');
$crontab->prefix = $DBprefix;
$crontab->connectDatabase('localhost','user','password','database');
$crontab->title = $_POST["title"];
$crontab->setDateParams($min, $hour, $day, $month, "*");
$crontab->setCommand("wget http://somedomain.com/index.php?mod=sendcron");
$crontab->savetodb();

/*
If you want to add more croncommand use:
$crontab->clearParameters();
$crontab->setDateParams(5, 10, 5, 5, "*");
$crontab->setCommand("curl http://somedomain.com/index.php?mod=sendcron");
$crontab->savetodb();
*/

$crontab->saveCronFilebydb();
$crontab->addToCrontab();
//$crontab->showerror();
$crontab->destroyFilePoint();
$crontab->closeDB();


/**********************************************************************************************/

//ANOTHER EXAMPLE TO RETRIEVE THE DATA FROM THE DB

require_once('class.cron.php');
$crontab=new crontab("/cron/", "filename", 'w');
$crontab->prefix = $DBprefix;
$crontab->connectDatabase('localhost','user','password','database');
$result = $crontab->retrievedb();

foreach(
$result as $key => $item) {
     echo
$item["title"]."<br>\n";
}

$crontab->closeDB();

?>