Source for file hrdi_db_class.php
Documentation is available at hrdi_db_class.php
* This file contains the {@link hrdi_db} class, a customized HRDI class
* extending the generic {@link mcpear} class.
* This file is part of HRDIODB.
* HRDIODB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* HRDIODB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with HRDIODB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** PEAR DB wrapper class */
require_once('mcpear_class.php');
* An inherited class containing HRDI database specific actions. The class
* contains all of the mcpear methods but adds HRDI specific functionality.
* HRDI specific add function.
* This function adds the creation date and time to the data and calls the
* parent's add() function.
* @param array $values Associative array of keys and values
* @param string $table Table name
* @return mixed Query result resource or FALSE on error
function add ($values, $table) {
return parent::add($values, $table);
* HRDI specific update function.
* This function adds a history entry for this update, adds the update
* date and time to the data and then calls the parent's update() function.
* @param array $values Associative array of key values
* @param string $table Table name
* @param string $where_key Where clause
* @return mixed Query result resource or FALSE on error
function update($values, $table, $where_key){
$update_key = "$where_key = '{$values[$where_key]}'";
$previous_data = $this->get_row($sql);
$values['Modified'] = $this->datetime();
return parent::update($values, $table, $where_key);
* Creates a history entry.
* This function creates an entry in the HRDI history table. The entry is
* made for the specified $table. The $previous_data is serialized and added
* to the entry. The previous data can be later unserialized using the PHP
* {@link PHP_MANUAL#unserialize} function.
* @param string $table The name of the table that was updated
* @param mixed $previous_data The data before the updated
* @return mixed Query result resource or FALSE on error
//$session = new session();
//$admin = $session->get_var("user_id");
$history['UserID'] = "0";
if(isset ($_SESSION['user_data']['ID'])){
$history['UserID']= $_SESSION['user_data']['ID'];
$history['Altered_Table'] = $table;
/* The previous data is serialized. It can be later restored by calling
the unserialize() method. */
$history['Previous_Data'] = serialize($previous_data);
return $this->add($history, "HRDI_History");
* ISO 8601 date and time.
* This function returns an ISO 8601 date and time used for created/updated
* @return string ISO 8601 date and time
return date("Y-m-d\TH:i:s");
|