Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

DB Logging actions

Questions related to using nuBuilder Forte.
Post Reply
shuray
Posts: 30
Joined: Sun Apr 23, 2023 3:36 pm
Has thanked: 10 times
Been thanked: 5 times

DB Logging actions

Unread post by shuray »

Hi everyone!

I would like to log any changes of my db tables to special table like:
  • time, user, table_name, [old field value - new field value, old field value - new field value, ...]

I can realize this feature using MySQL storing procedure and TRIGGERs, but on the SQL side I don't know the actual nuBuilder user.
Probably you can advise some ideas how to approach to this task?

Thx
nac
Posts: 115
Joined: Tue Dec 12, 2017 11:28 pm
Location: Aberdeen, UK
Has thanked: 9 times
Been thanked: 12 times

Re: DB Logging actions

Unread post by nac »

This thread has the code that you are looking for, shuray

https://forums.nubuilder.cloud/viewtopic.php?p=16394

Neil
nac
Posts: 115
Joined: Tue Dec 12, 2017 11:28 pm
Location: Aberdeen, UK
Has thanked: 9 times
Been thanked: 12 times

Re: DB Logging actions

Unread post by nac »

shuray,

One more thing..
I subsequently modified the code shown in the thread to use a prepared statement instead.

Code: Select all

$S = "REPLACE INTO changelog (changelog_id, tablename, fieldname, pkvalue, userid, oldvalue, newvalue) VALUES ( ?, ?, ?, ?, ?, ?, ? )";
nuRunQuery($S, [$ID, $Tbl, $Fld, $PK, $Usr, $OV, $NV]);
This makes it injection-safe.

Neil
shuray
Posts: 30
Joined: Sun Apr 23, 2023 3:36 pm
Has thanked: 10 times
Been thanked: 5 times

Re: DB Logging actions

Unread post by shuray »

Wow! Thank you!
Post Reply