| | |
| | | |
| | | <?php |
| | | /* |
| | | Copyright (c) 2005, Till Brehm, projektfarm Gmbh |
| | |
| | | private $record = array(); // last record fetched |
| | | private $autoCommit = 1; // Autocommit Transactions |
| | | private $currentRow; // current row number |
| | | private $errorNumber = 0; // last error number |
| | | public $errorNumber = 0; // last error number |
| | | public $errorMessage = ''; // last error message |
| | | private $errorLocation = '';// last error location |
| | | public $show_error_messages = false; // false in server, true in interface |
| | |
| | | } |
| | | |
| | | public function query($queryString) { |
| | | $this->queryId = parent::query($queryString); |
| | | parent::ping(); |
| | | $this->queryId = parent::query($queryString); |
| | | $this->updateError('DB::query('.$queryString.') -> mysqli_query'); |
| | | if(!$this->queryId) { |
| | | return false; |
| | |
| | | if(is_array($record_old) && count($record_old) > 0) { |
| | | foreach($record_old as $key => $val) { |
| | | // if(!isset($record_new[$key]) || $record_new[$key] != $val) { |
| | | if($record_new[$key] != $val) { |
| | | if(@$record_new[$key] != $val) { |
| | | // Record has changed |
| | | $diffrec_full['old'][$key] = $val; |
| | | $diffrec_full['new'][$key] = $record_new[$key]; |
| | | $diffrec_full['new'][$key] = @$record_new[$key]; |
| | | $diff_num++; |
| | | } else { |
| | | $diffrec_full['old'][$key] = $val; |
| | |
| | | return array('diff_num' => $diff_num, 'diff_rec' => $diffrec_full); |
| | | |
| | | } |
| | | |
| | | //** Function to fill the datalog with a full differential record. |
| | | |
| | | //** Function to fill the datalog with a full differential record. |
| | | public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new) { |
| | | global $app,$conf; |
| | | |
| | |
| | | if(isset($record_new['server_id'])) $server_id = $record_new['server_id']; |
| | | |
| | | |
| | | if($diff_num > 0) { |
| | | //print_r($diff_num); |
| | | //print_r($diffrec_full); |
| | | $diffstr = $app->db->quote(serialize($diffrec_full)); |
| | | $username = $app->db->quote($_SESSION['s']['user']['username']); |
| | | $dbidx = $primary_field.':'.$primary_id; |
| | | if($diff_num > 0) { |
| | | $diffstr = $this->quote(serialize($diffrec_full)); |
| | | if(isset($_SESSION)) { |
| | | $username = $this->quote($_SESSION['s']['user']['username']); |
| | | } else { |
| | | $username = 'admin'; |
| | | } |
| | | $dbidx = $primary_field.':'.$primary_id; |
| | | |
| | | if($action == 'INSERT') $action = 'i'; |
| | | if($action == 'UPDATE') $action = 'u'; |
| | | if($action == 'DELETE') $action = 'd'; |
| | | $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')"; |
| | | $app->db->query($sql); |
| | | } |
| | | if($action == 'INSERT') $action = 'i'; |
| | | if($action == 'UPDATE') $action = 'u'; |
| | | if($action == 'DELETE') $action = 'd'; |
| | | $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')"; |
| | | $this->query($sql); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | ?> |
| | | ?> |