Location: PHPKode > projects > astwebpanel > web/dao/ServerLogDao.php
<?php
/**
 * Copyright (C) 2004 - 2006, John Tarlton.
 *
 * This file is part of AstWebPanel - A web management user interface for Asterisk.
 *
 * AstWebPanel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation. See the LICENSE file distributed
 * with AstWebPanel.
 *
 * Database access object.
 */

require_once('./dao/Dao.php');

/**
 * Data Access Object for server log data.
 */
class ServerLogDao extends DBDao
{
	var $table = 'serverlog';

	function update($action)
	{
    	global $db;

		$query = "INSERT INTO {$this->table} (action) VALUES (?)";

  		$stmt = $db->prepare($query);	
		$querydata = array($action);

   		$result = $db->execute($stmt, $querydata); 
		return DB::isError ($result);
	}

	function getCount(&$pattern)
	{
		global $db;

		$sql = "SELECT count(*)";
		$from = "FROM {$this->table} ";
		$where = $this->buildWhere($pattern);

		$result = $db->query("$sql $from $where");
		$row = $result->fetchRow();
		return $row['count']; 
	}	

	function getMultiple( &$pattern, $offset, $limit, &$values)
	{
		global $db;

		$sql = "SELECT to_char(time, 'YYYY-MM-DD HH24:MI:SS') AS strtime, action";
		$from = "FROM {$this->table} ";
		$where = $this->buildWhere($pattern);

		$query = "$sql $from $where OFFSET $offset LIMIT $limit";
		$result = $db->query($query);
		while ($row = $result->fetchRow()) 
		{ 
			$values[] = $row;
		}
		$result->free();
	}
}


?>

Return current item: astwebpanel