if($this->debug)$app->log("Registered TableHook '$table_name' in module '$module_name' for processing function '$function_name'",LOGLEVEL_DEBUG);
}
/*
This function goes through all new records in the
sys_datalog table and and calls the function in the
modules that hooked on to the table change.
*/
functionprocessDatalog(){
global$app,$conf;
//* If its a multiserver setup
if($app->db->dbHost!=$app->dbmaster->dbHost){
$sql="SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
$records=$app->dbmaster->queryAllRecords($sql);
foreach($recordsas$d){
if(!$data=unserialize(stripslashes($d["data"]))){
$data=unserialize($d["data"]);
}
$replication_error=false;
$this->current_datalog_id=$d["datalog_id"];
if(count($data['new'])>0){
if($d["action"]=='i'||$d["action"]=='u'){
$idx=explode(":",$d["dbidx"]);
$tmp_sql1='';
$tmp_sql2='';
foreach($data['new']as$fieldname=>$val){
$tmp_sql1.="`$fieldname`,";
$tmp_sql2.="'$val',";
}
$tmp_sql1=substr($tmp_sql1,0,-1);
$tmp_sql2=substr($tmp_sql2,0,-1);
//$tmp_sql1 .= "$idx[0]";
//$tmp_sql2 .= "$idx[1]";
$sql="REPLACE INTO $d[dbtable] ($tmp_sql1) VALUES ($tmp_sql2)";
$app->log("Error in Replication, changes were not processed.",LOGLEVEL_ERROR);
/*
* If there is any error in processing the datalog we can't continue, because
* we do not know if the newer actions require this (old) one.
*/
return;
}
}else{
$app->log("Datalog does not conatin any changes for this record ".$d["datalog_id"],LOGLEVEL_DEBUG);
}
}
//* if we have a single server setup
}else{
$sql="SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
if($this->debug)$app->log("Registered TableHook '$table_name' in module '$module_name' for processing function '$function_name'",LOGLEVEL_DEBUG);
}
/*
This function goes through all new records in the
sys_datalog table and and calls the function in the
modules that hooked on to the table change.
*/
functionprocessDatalog(){
global$app,$conf;
//* If its a multiserver setup
if($app->db->dbHost!=$app->dbmaster->dbHost){
$sql="SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
$app->log("Error in Replication, changes were not processed.",LOGLEVEL_ERROR);
/*
* If there is any error in processing the datalog we can't continue, because
* we do not know if the newer actions require this (old) one.
*/
return;
}
}else{
$app->log("Datalog does not conatin any changes for this record ".$d["datalog_id"],LOGLEVEL_DEBUG);
}
}
//* if we have a single server setup
}else{
$sql="SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
$records=$app->db->queryAllRecords($sql);
foreach($recordsas$d){
//** encode data to utf-8 to be able to unserialize it and then unserialize it