Gossamer Forum
Home : Products : DBMan SQL : Development, Plugins and Globals :

real name in user table

Quote Reply
real name in user table
i will have 10-12 tables in my database and each will have its own user table. one of my tables is a membership file and only users who are in this table can be granted permissions in any table. several questions:

1. i don't want a Name field in each user table. however, i would like to display the name from the membership table where this field is displayed. how do i look up the real name from the membership table? (the username in the membership table will match the username in each user table)

2. when i create a new user in any user table, i would like to validate the username against the membership table.
Quote Reply
Re: [delicia] real name in user table In reply to
i figured out number 1 by using another thread:
sub {
my ($table, $field, $value) = @_;
my $sth = $DB->table($table)->select({ $field => $value });
my @output;
while (my $rs = $sth->fetchrow_hashref ) {
push @output, $rs;
return { loop_hash => \@output };

however, this looks like a one-to-many relationship and my purpose will always be one-to-one. i think i should get rid of the while, but probably need a different statement to get the one record that matches my username. what should i change?

and i still need help with #2. thanks