I finally had the time to check it out, your solution should be really
to clarify:
- one user can be the member of <many> groups
- one group can have <many> members
I thought that was n on m relation, but oh well :)

there's no relation groups, but instead a pg_group and pg_user (real
database users, no new table users or groups, I wanted to eliminate that
so in postgresql I do:
\d pg_group
And the outcome is something like this (it's on another computer, so I
could not copy paste)
Attribute Type      (modifier, but there are none)
groname   name
grousysid integer
grolist        integer[] (<- those are square brackets in case it's hard to
Indeces: pg_group_name_index,

When I tried to do a:
SELECT * FROM pg_group WHERE "grolist"='1005';
I get this error:
ERROR: array_in: Need to specify dimension

I think there's my problem, I don't know how to do that...

(I do my queries always first in pgsql first, then I parse them to php, to
make sure the query will work)
When I do a SELECT * FROM pg_group;
I get this list:
groname   grosysid  grolist
admins         1         {1004}
coders         5         {1006, 1005}
areas          4         {1006,1005}

Now I want the user that logs in with his/her name, and has uid 1005, to
get the options that belong to the groups he's member of.
So I need to filter something like this:
SELECT * FROM pg_group WHERE < his uid is in the grolist>;
but how can I manage that?

Hope I have been clearer this time...

                    Steve Brett                                                        
                    <steve.brett@e-       To:     [EMAIL PROTECTED]            
                    mis.co.uk>            cc:                                          
                                          Fax to:                                      
                    05-09-2001            Subject:     Re: postgresql groups and users 

"Michiel Lange" <[EMAIL PROTECTED]> wrote in message
> for my application in php I connect with a postgresql database.
> In this database I have made users and groups, where 1 user can be the
> member of many groups (n on m relation)
1 to many. 1 > n.

> That works, but how do I let php find out if a user is a member of a
> certain group?

do a select . i'm assuming that you post the user id into the groups

select * from goups where group_id=7 and user_id=1;

if the query returns any results then you have a match.

so :

if ($numrows>0){print"You have a match<br>";}


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to