This topic is locked

Adding Common Routines to template (Auditing)

8/19/2008 9:17:21 PM
PHPRunner General questions
A
anicewick author

I want to create a common auditing routine to embed in all the update,add and delete pages. I have it working O.K., However, I wanted to see if I can add it as a common routine so I don't have to code it over and over again.
The add events looks like the following:
function AfterAdd(&$values,&$keys,$inline)

{

$tablename = 'tblInstructions';

$pkname = 'Instruction_id';

$strSQLid = "select IDENT_CURRENT('".$tablename."') as pk";

global $conn;

$rs = db_exec($strSQLid,$conn);

if ($datacs=db_fetch_array($rs)) {

$pk = $datacs["pk"];}

$strValues1 = "'<".$pkname."=".$pk.">'";

$strSQLInsert = "insert into Audit

(PK,Type,TableName,FieldName,OldValue,NewValue,UpdateDate,UserName)

values (".$strValues1.",'I' ,'".$tablename."','LastUpateUser','','', getdate(),'".$_SESSION["UserID"]."')";

db_exec($strSQLInsert,$conn);

}
Can I make this event part of the template, so I don't need to retype it for every "add", "update" and "Delete" event ?

J
Jane 8/20/2008

Hi,
use Save project as template option to save current project as template and then use it to create new projects.