| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Libteiser - Ojs/ojs2/classes/scheduledTask/ |
Upload File : |
<?php
/**
* @defgroup scheduledTask
*/
/**
* @file classes/scheduledTask/ScheduledTaskDAO.inc.php
*
* Copyright (c) 2003-2009 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class ScheduledTaskDAO
* @ingroup scheduledTask
* @see ScheduledTask
*
* @brief Operations for retrieving and modifying Scheduled Task data.
*/
// $Id: ScheduledTaskDAO.inc.php,v 1.12.2.1 2009/04/08 19:42:49 asmecher Exp $
import('scheduledTask.ScheduledTask');
class ScheduledTaskDAO extends DAO {
/**
* Get the last time a scheduled task was executed.
* @param $className string
* @return int
*/
function getLastRunTime($className) {
$result = &$this->retrieve(
'SELECT last_run FROM scheduled_tasks WHERE class_name = ?',
$className
);
if ($result->RecordCount() == 0) {
$returner = 0;
} else {
$returner = strtotime($this->datetimeFromDB($result->fields[0]));
}
$result->Close();
unset($result);
return $returner;
}
/**
* Update a scheduled task's last run time.
* @param $className string
* @param $timestamp int optional, if omitted the current time is used
*/
function updateLastRunTime($className, $timestamp = null) {
$result = &$this->retrieve(
'SELECT COUNT(*) FROM scheduled_tasks WHERE class_name = ?',
$className
);
if (isset($result->fields[0]) && $result->fields[0] != 0) {
if (isset($timestamp)) {
$returner = $this->update(
'UPDATE scheduled_tasks SET last_run = ' . $this->datetimeToDB($timestamp) . ' WHERE class_name = ?',
array($className)
);
} else {
$returner = $this->update('UPDATE scheduled_tasks SET last_run = NOW() WHERE class_name = ?', array($className));
}
} else {
if (isset($timestamp)) {
$returner = $this->update(
sprintf('INSERT INTO scheduled_tasks (class_name, last_run)
VALUES (?, %s)', $this->datetimeToDB($timestamp)),
array($className)
);
} else {
$returner = $this->update(
'INSERT INTO scheduled_tasks (class_name, last_run)
VALUES (?, NOW())',
$className
);
}
}
$result->Close();
unset($result);
return $returner;
}
}
?>