Page 1 of 1

How to put current user into table (to see who create record

Posted: Mon Dec 21, 2015 1:54 pm
by maw2be
I need to put into table column with user, to see who create record and thanks to this user can see only "his" cases. As for me php, sql and rest is something new so I ask.
can you help me how to put into field/object administrator details of user who create it?

Re: How to put current user into table (to see who create re

Posted: Mon Dec 21, 2015 11:19 pm
by admin
maw2be,

Adding certain fields to a table will automatically record user information.. http://wiki.nubuilder.net/nubuilderv3/i ... ave_Button

Steven

Re: How to put current user into table (to see who create re

Posted: Fri Jan 08, 2016 6:09 pm
by maw2be
thanks
but i need to see who create "row" so I create table USER and compare USER to #nu_user_name#

Re: How to put current user into table (to see who create re

Posted: Mon Jan 11, 2016 6:36 am
by admin
maw2be,

You could try something like this.

Code: Select all

$s = "
    UPDATE toy
    SET toy_user_id = '#nu_user_name#'
    WHERE toy_user_id = ''

";

nuRunQuery($s);
And put it here..
Capture1.PNG
Capture1.PNG (17.49 KiB) Viewed 18433 times
Steven

Re: How to put current user into table (to see who create re

Posted: Fri Jan 22, 2016 4:53 pm
by maw2be
Thanks
Can you expand this littlebit?
I thinking about make additional column "modified by" where I will see who and when last time save this. can you help? With insert into SQL should be ok, problem is with searching last position so i can see who was last one.
admin wrote:maw2be,

You could try something like this.

Code: Select all

$s = "
    UPDATE toy
    SET toy_user_id = '#nu_user_name#'
    WHERE toy_user_id = ''

";

nuRunQuery($s);
And put it here..
Capture1.PNG
Steven

Re: How to put current user into table (to see who create re

Posted: Tue Jan 26, 2016 10:06 am
by Ion2
Dear maw2be,

let's support each other, as mentioned previously by Steven, the Save Button fulfills your demand of logging who last modified the data set.

You need to add the following to your table:

Code: Select all

ALTER TABLE ??  
ADD ??_log_added_at DATETIME NOT NULL,  
ADD ??_log_added_by VARCHAR(25) NOT NULL,
ADD ??_log_changed_at DATETIME NOT NULL,  
ADD ??_log_changed_by VARCHAR(25) NOT NULL,
ADD ??_log_viewed_at DATETIME NOT NULL,  
ADD ??_log_viewed_by VARCHAR(25) NOT NULL
Replace ?? with the name of your table.

Source: http://wiki.nubuilder.net/nubuilderv3/i ... ave_Button


It automaticly adds the zzzsys_user_id from the zzzsys_user table to the ??_log_xyz_by fields above, and works very fine for me. Than you need to make an inner join to the zzzsys_user table to get the real names.

I'm still struggling with the inner join. Help very much appreciated.

You'll find my post to this topic here: http://forums.nubuilder.cloud/viewtopic.php?f=13&t=8866

Greetings,
Timo

Re: How to put current user into table (to see who create re

Posted: Fri Feb 12, 2016 2:03 am
by admin
maw2be,

Timo's answer is the better way to do it.

Steven

Re: How to put current user into table (to see who create re

Posted: Thu Jan 18, 2018 12:07 pm
by pyro
Hi,

I tried to follow the instruction however the system does not automatically fill the information:
phpmyadmin.PNG
phpmyadmin.PNG (342.89 KiB) Viewed 14781 times
Any ideas why it does not work

Re: How to put current user into table (to see who create re

Posted: Thu Jan 18, 2018 12:22 pm
by pyro