J
|
Jane 11/22/2006 |
Hi, function BeforeAdd(&$values) { global $conn; $strSQLInsert = "insert into _Log (Date_Time, Event, User_ID) values(now(),'add record # ".$values["FieldName"]."', '".$_SESSION['UserID']."')"; db_exec($strSQLInsert,$conn); return true; } function BeforeEdit(&$values, $where) { global $conn; $strSQLInsert = "insert into _Log (Date_Time, Event, User_ID) values(now(),'edit record # ".$values["FieldName"]."', '".$_SESSION['UserID']."')"; db_exec($strSQLInsert,$conn); return true; } function BeforeDelete($where) { global $conn; $str = "select * from TableName where ".$where; $rs = db_query($str,$conn); $data = db_fetch_array($rs); $strSQLInsert = "insert into _Log (Date_Time, Event, User_ID) values(now(),'delete record # ".$data["FieldName"]."', '".$_SESSION['UserID']."')"; db_exec($strSQLInsert,$conn); return true; }
|
A
|
afdesigns author 11/22/2006 |
Thanks! Little issue though. The primary key for the records that I want to track is an auto increment serial number that should not be edit'able. The only way I can get that number to show up on the log is to make it fully edit'able. Putting it on the edit page, but making it read only doesn't seem to do the trick either. Ideas? |
J
|
Jane 11/22/2006 |
If you field is autoincrement use AfterAdd and BeforeEdit events. function AfterAdd() { global $conn; $str = "select last_insert_id() from TableName"; $rs = db_query($str,$conn); $data = db_fetch_numarray($rs); $strSQLInsert = "insert into _Log (Date_Time, Event, User_ID) values(now(),'add record # ".$data[0]."', '".$_SESSION['UserID']."')"; db_exec($strSQLInsert,$conn); } function BeforeEdit(&$values, $where) { global $conn; $str = "select * from TableName where ".$where; $rs = db_query($str,$conn); $data = db_fetch_array($rs); $strSQLInsert = "insert into _Log (Date_Time, Event, User_ID) values(now(),'edit record # ".$data["FieldName"]."', '".$_SESSION['UserID']."')"; db_exec($strSQLInsert,$conn); return true; } |