<?php
// class.undo.php manages database records updates/undo
// Copyright (C) 2005 Yo Keller
// the sql code for the undo_tbl creation
$undo_tbl_sql =<<<USQL
CREATE TABLE undo_tbl (
id int(10) unsigned NOT NULL auto_increment,
tble text NOT NULL,
tbl_id int(10) NOT NULL,
col text NOT NULL,
enregi text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Created by mkFormGen' AUTO_INCREMENT=1 ;
USQL;
// to fetch all the undo values for the recent updates of any given record
$all_upd_sql = <<<ASQL
SELECT @m:=id,@t:=tble FROM undo_tbl WHERE col='--#tag#--';
SELECT col,enregi FROM undo_tbl where id > @m and tble = @t
ASQL;
// to fetch all the undo values for the recent updates of a given record col
$all_upd_del_sql = <<<DSQL
SELECT @m:=id,@t:=tble,@tid:=tbl_id FROM undo_tbl WHERE col='--#tag#--';
DELETE FROM undo_tbl where id >= @m and tble = @t and tbl_id = @tid
DSQL;
// to fetch all the undo values for the recent updates of a given record col
$all_upd_del_sql_0 = <<<DSQL0
SELECT @m:=id,@t:=tble,@tid:=tbl_id FROM undo_tbl WHERE col='--#tag#--';
SELECT * FROM undo_tbl where id >= @m and tble = @t and tbl_id = @tid
DSQL0;
// to fetch all the undo values for the recent updates of a given record -- given its table and id
$all_tbl_upd_sql = <<<ATSQL
SELECT @m:=id FROM undo_tbl WHERE col='--#tag#--' and tble = 'ma_table' and tbl_id = 1789;
SELECT col,enregi FROM undo_tbl where id > @m and tble = 'ma_table' and tbl_id = 1789
ATSQL;
// to fetch recent updates to a dummy undo
$all_rec_upd=<<<ARU
SELECT col,enregi FROM undo_tbl where id > _dum and tble = 'ma_table' and tbl_id = 1789
ARU;
// to fetch all the undo values for the recent updates of a given record -- given its table and id
$all_tbl_col_upd_sql = <<<ATCSQL
SELECT @m:=id FROM undo_tbl WHERE col='--#tag#--' and tble = 'ma_table' and tbl_id = 1789 ;
SELECT enregi FROM undo_tbl where id > @m and tble = 'ma_table' and tbl_id = 1789 and col ='ma_col'
ATCSQL;
/*
// typical use
$my_undo = new dbUndo();
$my_undo->init('config.inc.php');
if (!$my_undo->setup()){
echo "cannot setup the undo machinery!!!<br />\n";
}
*/
class dbUndo {
/////////////////////////////////////////////////
// PUBLIC VARIABLES
/////////////////////////////////////////////////
var $hostname;
var $username;
var $password;
var $dbname;
var $undo_tbl_name = 'undo_tbl';
var $verb = 0;
var $cur_tbl_keyname = 'id';
var $db_h = 0;
/////////////////////////////////////////////////
// METHODS
//
// dbUndo constructor
// init init from a config file
// dbConnect database connection
// dbDisconnect close database connection
// chk_undo_tbl check whether the undo_tbl exists already
// setup puts together a setup for the undo machinery
// check_record checks the existence of a given record
// mark_record insert a tag indicating the start-point of an update sequence
// mark_dummy_record insert a tag indicating the start-point of a dummy undo record
// mark_record_upd save data to be restored if undo ... is requested
// delete_recent_undo_data delete all undo records for the most recent update of a given table
// update_col update a given record while recording its undo
// update_col_dummy simulate a record update -- while there is no actual record
// undo_all_recent_updates undo all for a given record
// undo_all_recent_col_updates undo all for a given record given a specific column
// apply_updates record into db all the fld_value pairs provided as argument
// apply_all_recent_updates create a new record containing all the recent updates concerning a yet undefined record
// mult_qry process multiple queries
/////////////////////////////////////////////////
function dbUndo($hostname='',$username='',$password='',$dbname='')
{
$this->hostname = $hostname;
$this->username = $username;
$this->password = $password;
$this->dbname = $dbname;
$this->db_h = 0;
}
// init from a conf file containing definitions for
// $dbhost,$dbuser,$dbpwd,$dbname
function init($fconf)
{
if (!is_file($fconf))
return;
include($fconf);
$this->hostname = $dbhost;
$this->username = $dbuser;
$this->password = $dbpwd;
$this->dbname = $dbname;
}
function dbConnect()
{
if (empty($this->hostname) ||
empty($this->username) ||
empty($this->dbname)){
if ($this->verb) echo "dbUndo::dbConnect WARNING: insufficient data to connect<br />\n";
return false;
}
$this->db_h = mysql_connect($this->hostname,$this->username,$this->password);
if (!$this->db_h){
if ($this->verb) echo "dbUndo::dbConnect ERROR: erroneous data to connect<br />\n";
return false;
}
$result = mysql_select_db($this->dbname);
$found = (empty($result)?'false':'true');
if ($this->verb) echo "dbUndo::dbConnect database ".$this->dbname." found? ".$found." !<br />\n";
if (empty($result))
return false;
return $this->db_h;
} // end function dbConnect
function dbDisconnect()
{
if (!empty($this->db_h))
@mysql_close($this->db_h);
$this->db_h = 0;
}
function chk_undo_tbl()
{
if (empty($this->db_h))
return false; // cannot check if disconnected!
$result = mysql_list_tables($this->dbname);
if (!$result) {
echo "dbUndo::chk_undo_tbl -- Erreur : impossible de lister les bases de données<br />\n";
echo 'Erreur MySQL : ' . mysql_error();
return false;
}
while ($row = mysql_fetch_row($result)) {
if ($this->verb) echo "dbUndo::chk_undo_tbl:Table : $row[0]<br />\n";
if ($row[0] == $this->undo_tbl_name){
mysql_free_result($result);
if ($this->verb) echo "dbUndo::chk_undo_tbl: SUCCESS!<br />\n";
return true;
}
}
mysql_free_result($result);
if ($this->verb) echo "dbUndo::chk_undo_tbl:FAILURE!<br />\n";
return false;
} // end function chk_undo_tbl
function setup()
{
global $undo_tbl_sql;
if (!$this->dbConnect())
return false; // cannot setup the undo machinery
if (!$this->chk_undo_tbl()){
// adapt the undo_tbl creation qry
$tbl_sql = str_replace('undo_tbl',$this->undo_tbl_name,$undo_tbl_sql);
if ($this->verb) echo "dbUndo::setup:SQL creation of undo_tbl starts!<br />\n";
// create the undo_tbl
$result = mysql_query($tbl_sql);
if (!$result) {
echo 'Erreur dbUndo::setup : ' . mysql_error()." while applying ".$tbl_sql."<br />\n";
return false; // cannot setup the undo machinery
}
if ($this->verb) echo "dbUndo::setup:SQL creation of undo_tbl SUCCESS!<br />\n";
} // end if !chk_undo_tbl()
return true; // setup is completed
} // end function setup()
// check the existence of a given table record
function check_record($tbl,$id, $tbl_keyname='id')
{
if ($this->verb) echo "dbUndo::check_record -- table: $tbl id: $id <br />\n";
$this->cur_tbl = $tbl;
$this->cur_id = $id;
$this->cur_tbl_keyname = $tbl_keyname;
$this->cur_col = '';
// are these valid indications?
$qry = "select ".$this->cur_tbl_keyname." from ".$this->cur_tbl." where ".$this->cur_tbl_keyname." = ".$id;
$result = mysql_query($qry);
if (empty($result)){
echo "dbUndo::check_record -- ".$qry."--".mysql_errno().": ".mysql_error()."<br />\n";
$this->cur_tbl = '';
$this->cur_id = 0;
return false;
}
while ($row = mysql_fetch_row($result)){
if ($this->verb) echo "dbUndo::check_record : $row[0]<br />\n";
if ($row[0] == $id){
mysql_free_result($result);
if ($this->verb) echo "dbUndo::check_record : SUCCESS<br />\n";
return true;
}
}
mysql_free_result($result);
if ($this->verb) echo "dbUndo::check_record : FAILURE<br />\n";
$this->cur_tbl = '';
$this->cur_id = 0;
return false;
} // end check_record
// create a mark for a session concerning a given table record
function mark_record($tbl,$id, $tbl_keyname='id')
{
if (!$this->check_record($tbl,$id, $tbl_keyname))
return false;
// create a tag in the undo_tbl having as contents a key-word and the current date
$date = date("r");
$qry = "insert into ".$this->undo_tbl_name." (tble,tbl_id,col, enregi) values ('".$tbl."','".$id."','--#tag#--','".$date."') ";
$result = mysql_query($qry);
if (empty($result)){
echo "dbUndo::mark_record -- ".$qry."--".mysql_errno().": ".mysql_error()."<br>";
return false;
}
$new_id = mysql_insert_id(); //mysql_insert_id($this->db_h);
if ($this->verb) echo "dbUndo::mark_record (".$new_id.")-('".$tbl."','".$id."','--#tag#--','".$date."')- SUCCESS<br>";
return $new_id;
} // end mark_record
// create a mark for a session concerning a not yet defined table record
function mark_dummy_record($tbl)
{
$this->cur_tbl = $tbl;
$this->cur_id = 0;
$this->cur_tbl_keyname = 'id'; // default
$this->cur_col = '';
// create a tag in the undo_tbl having as contents a key-word and the current date
$date = date("r");
$qry = "insert into ".$this->undo_tbl_name." (tble,tbl_id,col, enregi) values ('".$tbl."','0','--#tag#--','".$date."') ";
if ($this->verb) echo "dbUndo::mark_dummy_record qry: ($qry)<br />\n";
$result = mysql_query($qry);
if (empty($result)){
echo "dbUndo::mark_dummy_record -- ".$qry."--".mysql_errno().": ".mysql_error()."<br />\n";
return false;
}
$new_id = mysql_insert_id(); //mysql_insert_id($this->db_h);
if ($this->verb) echo "dbUndo::mark_dummy_record -- new undo_tbl record id ".$new_id."<br />\n";
// update the tag by inserting as tbl_id -$new_id
$upd_qry = "update ".$this->undo_tbl_name." set tbl_id='-".$new_id."' where id='".$new_id."'";
$new_id = -$new_id;
$res = mysql_query($upd_qry);
if ($this->verb) echo "dbUndo::mark_dummy_record upd_qry: ($upd_qry)<br />\n";
if (empty($res)){
echo "dbUndo::mark_dummy_record -- ".$upd_qry."--".mysql_errno().": ".mysql_error()."<br />\n";
}
if ($this->verb) echo "dbUndo::mark_dummy_record ($new_id)-('".$tbl."','".$new_id."','--#tag#--','".$date."')- SUCCESS<br />\n";
return $new_id;
} // function mark_dummy_record
// create a record for a specific field update within a session concerning a given table record
function mark_record_upd($col )
{
if (empty($this->cur_tbl) || empty($this->cur_id)){
if ($this->verb) echo "dbUndo::mark_record_upd -- no available mark for record change<br />\n";
return false;
}
if (empty($col)){
if ($this->verb) echo "dbUndo::mark_record_upd -- no available column name<br />\n";
return false;
}
$this->cur_col = $col;
// record present value
$qry_sel = "select ".$col." from ".$this->cur_tbl." where ".$this->cur_tbl_keyname." = ".$this->cur_id;
$result = mysql_query($qry_sel);
if (empty($result)){
echo "dbUndo::mark_record_upd -- ".$qry_sel."--".mysql_errno().": ".mysql_error()."<br />\n";
return false;
}
$data_to_save = '';
while ($row = mysql_fetch_row($result)){
if ($this->verb) echo "dbUndo::mark_record_upd : $row[0]<br />\n";
$data_to_save .= $row[0];
}
mysql_free_result($result);
if ($this->verb) echo "dbUndo::mark_record_upd : save $data_to_save<br />\n";
// record in th undo table
$qry = "insert into ".$this->undo_tbl_name." (tble,tbl_id,col, enregi) values ('".$this->cur_tbl."','".$this->cur_id."','".$col."','".$data_to_save."') ";
$result = mysql_query($qry);
if (empty($result)){
echo "dbUndo::mark_record -- ".$qry."--".mysql_errno().": ".mysql_error()."<br>";
return false;
}
$new_id = mysql_insert_id(); //mysql_insert_id($this->db_h);
echo "dbUndo::mark_record_upd ($new_id)-('".$this->cur_tbl."','".$this->cur_id."','".$col."','".$data_to_save."')- SUCCESS<br>";
return $data_to_save;
} // end function mark_record_upd
// delete all the most recent undo-updates concerning a given record
function delete_recent_undo_data()
{
global $all_upd_del_sql,$all_upd_del_sql_0;
if (!$this->dbConnect())
return false; // cannot apply the undo machinery
$result = $this->mult_qry($all_upd_del_sql_0);
if (empty($result)){
echo "dbUndo::delete_recent_undo_data -- ".$all_upd_del_sql_0."--".mysql_errno().": ".mysql_error()."<br />\n";
return false;
}
if ($this->verb){
$data_to_del = array();
while ($row = mysql_fetch_row($result)){
$data_to_del[] = $row;
}
echo "data deleted: <br />\n";
print_r($data_to_del);
echo "<br />\n";
}
mysql_free_result($result);
$result = $this->mult_qry($all_upd_del_sql);
if (empty($result)){
echo "dbUndo::delete_recent_undo_data -- ".$all_upd_del_sql."--".mysql_errno().": ".mysql_error()."<br />\n";
return false;
}
mysql_free_result($result);
return true;
} // end delete_recent_undo_data
// update a given record column
// assert: $tbl, $id record has already been marked for update
// using mark_record($tbl,$id, $tbl_keyname='id')
function update_col($col,$data)
{
// save the data for a possible undo
$old_data = $this->mark_record_upd($col );
if ($data == $old_data){
if ($this->verb) echo "dbUndo::update_col : $col unchanged!<br />\n";
return $data;
}
// actually update the col data
$upd_qry = "update ".$this->cur_tbl." set ".$col."='".$data."' where ".$this->cur_tbl_keyname."='".$this->cur_id."'";
if ($this->verb) echo "dbUndo::update_col query: $upd_qry<br />\n";
$res = mysql_query($upd_qry);
if (empty($res)){
echo "dbUndo::update_col -- ".$upd_qry."--".mysql_errno().": ".mysql_error()."<br>";
}
return $old_data;
} // function update_col
function update_col_dummy($tbl,$dum_id,$col,$data)
{
// save the data -- provide for a possible undo
// actually insert the col data in the undo_tbl
//$upd_qry = "update ".$this->undo_tbl_name." set ".$col."='".$data."' where tble = '".$tbl."' and tbl_id='".$dum_id."'";
$qry = "insert into ".$this->undo_tbl_name." (tble,tbl_id,col, enregi) values ('".$tbl."','".$dum_id."','".$col."','".$data."') ";
if ($this->verb) echo "dbUndo::update_col_dummy query: $qry<br />\n";
$res = mysql_query($qry);
if (empty($res)){
echo "dbUndo::update_col_dummy -- ".$qry."--".mysql_errno().": ".mysql_error()."<br>";
return false;
}
return $data;
} // function update_col_dummy
// undo all the recent updates concerning the record $tbl, $id
function undo_all_recent_updates($tbl,$id,$tbl_keyname='id')
{
global $all_tbl_upd_sql;
if (!$this->dbConnect())
return false; // cannot apply the undo machinery
if (!$this->check_record($tbl,$id, $tbl_keyname))
return false;
// adapt the undo_tbl all_upd_sql qry
$tbl_sql = str_replace('undo_tbl',$this->undo_tbl_name,$all_tbl_upd_sql);
$tbl_sql = str_replace('ma_table',$tbl,$tbl_sql);
$tbl_sql = str_replace('1789',$id,$tbl_sql);
if ($this->verb) echo "dbUndo::undo_all_recent_updates query: $tbl_sql<br />\n";
// collect all the recent udaptes for the given record
$result = $this->mult_qry($tbl_sql); //mysql_query($tbl_sql);
if (empty($result)){
echo "dbUndo::undo_all_recent_updates -- ".$tbl_sql."--".mysql_errno().": ".mysql_error()."<br />\n";
$this->cur_tbl = '';
$this->cur_id = 0;
return false;
}
// collect all the changes -- and restore them in reverse order
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
if ($this->verb) echo "dbUndo::undo_all_recent_updates: "; print_r($row); echo "<br />\n";
$rows[] = $row;
}
mysql_free_result($result);
//
for($i=count($rows);$i>0;$i--)
{
$col = $rows[$i-1]['col'];
$data = $rows[$i-1]['enregi'];
$upd_qry = "update ".$tbl." set ".$col."='".$data."' where ".$this->cur_tbl_keyname."='".$id."'";
if ($this->verb) echo "dbUndo::undo_all_recent_updates query: $upd_qry<br />\n";
$res = mysql_query($upd_qry);
if (empty($res)){
echo "dbUndo::undo_all_recent_updates -- ".$upd_qry."--".mysql_errno().": ".mysql_error()."<br>";
}
}
if ($this->verb) echo "dbUndo::undo_all_recent_updates ".count($rows)." rows of updates ...<br />\n";
if (count($rows) ==0)
return true;
else
return count($rows);
} // end function undo_all_recent_updates
// undo all the recent updates concerning the record $tbl, $id and column $col
function undo_all_recent_col_updates($tbl,$id,$col,$tbl_keyname='id')
{
global $all_tbl_col_upd_sql;
if (!$this->dbConnect())
return false; // cannot apply the undo machinery
if (!$this->check_record($tbl,$id, $tbl_keyname))
return false;
// adapt the undo_tbl all_tbl_col_upd_sql qry
$tbl_sql = str_replace('undo_tbl',$this->undo_tbl_name,$all_tbl_col_upd_sql);
$tbl_sql = str_replace('ma_table',$tbl,$tbl_sql);
$tbl_sql = str_replace('1789',$id,$tbl_sql);
$tbl_sql = str_replace('ma_col',$col,$tbl_sql);
if ($this->verb) echo "dbUndo::undo_all_recent_col_updates query: $tbl_sql<br />\n";
// collect all the recent udaptes for the given record
$result = $this->mult_qry($tbl_sql); //mysql_query($tbl_sql);
if (empty($result)){
echo "dbUndo::undo_all_recent_col_updates -- ".$tbl_sql."--".mysql_errno().": ".mysql_error()."<br />\n";
$this->cur_tbl = '';
$this->cur_id = 0;
return false;
}
// collect all the changes -- and restore them in reverse order
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
if ($this->verb) echo "dbUndo::undo_all_recent_col_updates: "; print_r($row); echo "<br />\n";
$rows[] = $row;
}
mysql_free_result($result);
for($i=count($rows);$i>0;$i--)
{
$data = $rows[$i-1]['enregi'];
$upd_qry = "update ".$tbl." set ".$col."='".$data."' where ".$this->cur_tbl_keyname."='".$id."'";
if ($this->verb) echo "dbUndo::undo_all_recent_col_updates query: $upd_qry<br />\n";
$res = mysql_query($upd_qry);
if (empty($res)){
echo "dbUndo::undo_all_recent_col_updates -- ".$upd_qry."--".mysql_errno().": ".mysql_error()."<br>";
}
}
if ($this->verb) echo "dbUndo::undo_all_recent_col_updates : ".count($rows)." updates involved!<br />\n";
if (count($rows) == 0)
return true;
else
return count($rows);
} // end function undo_all_recent_col_updates
// given a list of fields and a matching list of values
// set $this->cur_tbl, $this->cur_id to these values
function apply_updates($tbl,$id, $field_values,$tbl_keyname='id')
{
if (!$this->dbConnect())
return false; // cannot apply the undo machinery
if (!$this->check_record($tbl,$id, $tbl_keyname))
return false;
$upd_lst = "";
foreach($field_values as $fld => $val){
$upd_lst .= ",".$fld."='".$val."'";
}
// remove the leading ","
$upd_lst = substr($upd_lst,1);
$qry = "update ".$tbl." set ".$upd_lst." where ".$tbl_keyname."='".$id."'";
if ($this->verb) echo "dbUndo::apply_updates query: $qry<br />\n";
$result = $this->mult_qry($qry); //mysql_query($tbl_sql);
if (empty($result)){
echo "dbUndo::apply_updates -- ".$qry."--".mysql_errno().": ".mysql_error()."<br />\n";
return false;
}
return $qry;
} // end function apply_updates
// apply all the recent updates concerning the record $tbl, and $id
// into a new record. NB: $id is -xxx where xxx is the id of the undo_tble tag
function apply_all_recent_updates($tbl,$id,$tbl_keyname='id')
{
global $all_rec_upd;
if (!$this->dbConnect())
return false; // cannot apply the undo machinery
// adapt the undo_tbl all_tbl_upd_sql qry
$tbl_sql = str_replace('undo_tbl',$this->undo_tbl_name,$all_rec_upd);
$tbl_sql = str_replace('ma_table',$tbl,$tbl_sql);
$tbl_sql = str_replace('1789',$id,$tbl_sql);
$id = -$id;
$tbl_sql = str_replace('_dum',$id,$tbl_sql);
if ($this->verb) echo "dbUndo::apply_all_recent_updates query: $tbl_sql<br />\n";
// collect all the recent udaptes for the given record
$result = $this->mult_qry($tbl_sql); //mysql_query($tbl_sql);
if (empty($result)){
echo "dbUndo::apply_all_recent_updates -- ".$tbl_sql."--".mysql_errno().": ".mysql_error()."<br />\n";
$this->cur_tbl = '';
$this->cur_id = 0;
return false;
}
// collect all the changes -- and apply them in increasing order
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
if ($this->verb) echo "dbUndo::apply_all_recent_updates: "; print_r($row); echo "<br />\n";
$rows[] = $row;
}
mysql_free_result($result);
// the following could be simplified into a single, i.e. UNIQUE, insert query !!!!
if (count($rows)==0){
if ($this->verb) echo "dbUndo::apply_all_recent_updates: nothing to update!<br />\n";
return false;
}
$fld_val = array();
for($i=0;$i<count($rows);$i++)
{
$col = $rows[$i]['col'];
$fld_val[$col] = $rows[$i]['enregi'];
}
if ($this->verb) echo "dbUndo::apply_all_recent_updates: fld_val "; print_r($fld_val); echo "<br />\n";
// create a new record
$qry_insert = "insert into ".$tbl;
$fields = '';
$values = '';
foreach ($fld_val as $k => $v)
{
$fields .= ",".$k;
$values .= ",'".$v."'";
}
// remove the leading ","
$fields = substr($fields,1);
$values = substr($values,1);
$qry_insert .= " (".$fields.") values (".$values.")";
$res = mysql_query($qry_insert);
if (empty($res)){
echo "dbUndo::apply_all_recent_updates -- ".$qry_insert."--".mysql_errno().": ".mysql_error()."<br>";
return false;
}
// recover the new id
$new_id = mysql_insert_id($this->db_h);
/*
// insert all the updates
//for($i=count($rows);$i>0;$i--)
for($i=0;$i<count($rows);$i++)
{
$col = $rows[$i]['col'];
$data = $rows[$i]['enregi'];
$upd_qry = "update ".$tbl." set ".$col."='".$data."' where ".$this->cur_tbl_keyname."='".$new_id."'";
if ($this->verb) echo "dbUndo::apply_all_recent_updates query: $upd_qry<br />\n";
$res = mysql_query($upd_qry);
if (empty($res)){
echo "dbUndo::apply_all_recent_updates -- ".$upd_qry."--".mysql_errno().": ".mysql_error()."<br>";
}
}
*/
if ($this->verb) echo "dbUndo::apply_all_recent_updates: ".count($rows)." record created: ".$new_id."<br />\n";;
return $new_id;
} // end function apply_all_recent_updates
// process multiple queries
function mult_qry($qry)
{
if ($this->verb) echo "dbUndo::mult_qry: $qry <br>\n";
$nb_qry = substr_count($qry,";");
if ($nb_qry == 0)
return mysql_query($qry);
// multiple queries
$qry_list = explode(";",$qry);
if ($this->verb) {echo "dbUndo::mult_qry: ".count($qry_list)." queries elementaires : ";
print_r($qry_list); echo "!<br>\n";}
reset($qry_list);
foreach($qry_list as $requete)
{
//if (empty(trim($requete))) continue;
if ($this->verb) echo "dbUndo::mult_qry:requete: $requete <br>\n";
//$requ = str_replace("<br />"," ",$requete);
//$requ = str_ireplace("<br>"," ",$requ);
$requ = trim($requete);
if (empty($requ)) continue;
if(!empty($res)) mysql_free_result ($res);
$res = mysql_query($requ);
if (empty($res)){
if ($this->verb) echo "dbUndo::mult_qry - $qry -- $requ -->: ".mysql_errno()." : ".mysql_error()."<br />";
return $res; // premature return
}
}
return $res;
} // end function mult_qry
} // end class dbUndo
?>