Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // We have 'tasks' table with PK 'sno'.
- $e["on_update"] = array("log_data", null, true);
- $e["on_insert"] = array("log_data", null, true);
- $e["on_delete"] = array("log_data", null, true);
- $grid->set_events($e);
- function log_data($data)
- {
- $rs = mysql_fetch_assoc(mysql_query("SELECT * FROM tasks WHERE sno = {$data[sno]}"));
- $data["old"] = $rs;
- if ($_POST["oper"] == "add") $oper = "Added";
- else if ($_POST["oper"] == "edit") $oper = "Updated";
- else if ($_POST["oper"] == "del") $oper = "Deleted";
- // here $data = new data, $data["old"] = old data and $oper is operation.
- $change_str = "";
- if (!empty($data["old"]))
- {
- // changelog track
- $changes = array();
- foreach ($data["params"] as $k=>$v)
- foreach ($data["old"] as $ok => $ov)
- if ($k == $ok && $v != $ov)
- {
- $ov = empty($ov) ? "(blank)" : $ov;
- $changes[] = "$k: $ov -> $v";
- }
- $change_str = implode(", ",$changes);
- }
- // execute the logging query
- }
- // Note that with on_delete event, you only get $data["sno"] and no new data (due to obvious reason)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement