get table name in dv hooks
-
- Posts: 27
- Joined: 2015-12-19 03:59
get table name in dv hooks
hello,do u know function how to get table name in the hooks
Re: get table name in dv hooks
Hi,
for a common logging-function I did the following couple of months ago:
Variable $table should contain the table name. You can adjust the function to your needs, for example return $table.
Integration
{TABLENAME} {underscore} {before|after} {underscore} {insert|update|delete}
...for example
myTableName_before_update
Attention
If you have tablenames containing "_" (underscore) you will have to modify my code.
Should be a good starting point anyway!
Kind Regards,
Jan
for a common logging-function I did the following couple of months ago:
Code: Select all
function log($data) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
$caller = $trace[1];
$functionname = $caller['function'];
list($table, $time, $action) = explode('_', $functionname);
// ...
}
Integration
- Put my function into your code
- from one of your hook functions call log($data);
- within my function check the variable $table
{TABLENAME} {underscore} {before|after} {underscore} {insert|update|delete}
...for example
myTableName_before_update
Attention
If you have tablenames containing "_" (underscore) you will have to modify my code.
Should be a good starting point anyway!
Kind Regards,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.14 Revision 1665 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.14 Revision 1665 + all AppGini Helper tools
-
- Posts: 27
- Joined: 2015-12-19 03:59
Re: get table name in dv hooks
thank youjsetzer wrote: ↑2019-06-24 15:01Hi,
for a common logging-function I did the following couple of months ago:
Variable $table should contain the table name. You can adjust the function to your needs, for example return $table.Code: Select all
function log($data) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); $caller = $trace[1]; $functionname = $caller['function']; list($table, $time, $action) = explode('_', $functionname); // ... }
Integration
It should work if you call it from any hook-function following the naming convention...
- Put my function into your code
- from one of your hook functions call log($data);
- within my function check the variable $table
{TABLENAME} {underscore} {before|after} {underscore} {insert|update|delete}
...for example
myTableName_before_update
Attention
If you have tablenames containing "_" (underscore) you will have to modify my code.
Should be a good starting point anyway!
Kind Regards,
Jan
i fixed it with my own way like this
$table_file=basename($_SERVER['SCRIPT_FILENAME']);
$tablename=substr($table_file,0, -9);
$tablename is the table name
hope this solution will help other in the future