. * * @package phpservermon * @author Pepijn Over * @copyright Copyright (c) 2008-2014 Pepijn Over * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 * @version Release: @package_version@ * @link http://www.phpservermonitor.org/ * @since phpservermon 3.1 **/ /** * Cleanup log table */ namespace psm\Util\Server\Archiver; use psm\Service\Database; class LogsArchiver implements ArchiverInterface { /** * Database service * @var \psm\Service\Database $db */ protected $db; function __construct(Database $db) { $this->db = $db; } /** * Currently there is not really a log archive. * * It stays in the log table until cleaned up. * @param int $server_id */ public function archive($server_id = null) { return true; } public function cleanup(\DateTime $retention_date, $server_id = null) { $sql_where_server = ($server_id !== null) // this is obviously not the cleanest way to implement this when using paramter binding.. sorry. ? ' `server_id` = ' . intval($server_id) . ' AND ' : ''; $this->db->execute( "DELETE FROM `".PSM_DB_PREFIX."log` WHERE {$sql_where_server} `datetime` < :latest_date", array('latest_date' => $retention_date->format('Y-m-d 00:00:00')), false ); return true; } }