Helpful Information
 
 
Category: Development Articles
User Authentication With patUser (part 2)

The database schema that patUser uses is a pretty common one, but I think it's a bit clunky to have three tables, users, groups and a user/group table.

I'm working on my own system with only a user table and a group table. I give the groups an ID that is a power of two, ie: 1, 2, 4, 8, 16, etc. What I do is put a group ID field on the user record. If a user is in groups 1 and 16, then that user's group ID is set to 17. I just do logical ANDs on the two tables to get the info I need.

Unfortunately, I only get 29 distinct IDs in an integer field, but I'm planning on experimenting with a VARCHAR field to see what I can get.

This is not specific to this article, but this article is the one that finally made me want to post this:

I like your PHP articles very much in general. In fact they have helped me a lot in the past.
However, your chapter titles make it extremely difficult to use the tutorials as a reference. If I'm looking for a specific bit in a tutorial I have read some time ago, chapter titles like "Meet the family" force me to skim through the whole article to find what I need, even when it is already oranized into topics.
No doubt, the creative naming makes reading more fun. But I think quick acces is more important here.

Otherwise, great article as always!

I like that idea. I was working on a setup where user ID's are stored in one of the fields in the group database. Each ID is seporated by a comma. Then I just explode the field when I need to see if a user is in a group.

It would work the other way as well, storing the users groups in a single field with commas.

User Authentication With patUser \(part 2\) (http://www.devshed.com/c/a/PHP/User-Authentication-With-patUser-part-2)

May 01, 2003
In this second part, find out how you can use the patUser API to view, add, edit and delete users (and user attributes) from your user database. Read full article .

Please discuss this article in this thread. You can read the article here (http://www.devshed.com/c/a/PHP/User-Authentication-With-patUser-part-2).

In the illustration at http://www.devshed.com/Server_Side/PHP/patUser/patUser2/page12.html the groups field won't display and when I view the source I get the following:

<select name="gid[]" multiple>
<br>
<b>Fatal error</b>: Call to a member function on a non-object in <b>/include/patUser.php</b> on line <b>2035</b><br>


Any ideas?

We'll look into this shortly and get back to you. Thanks for the heads up.

wow on line 2035 can you please post the 10 lines above 2035, also line 2035, and then the 10 lines below 2035? This will give me a better idea what might be causing the issue.

/**
* get groups from the grouptable
*
* @access public
* @param array $fields array containing fieldnames to be fetched
* @param array $clause array containing conditions for the where statement
* @param array $options array containing misc options
*/
function getGroups( $fields = array(), $clause = array(), $options = array() )
{
$query = $this->buildSelectQuery( $this->groupTable, $fields, $clause, $options );

// query database
$result = $this->authDbc->query( $query );
$data = $result->get_result( patDBC_TYPEASSOC );
$result->free();
return $data;
}

/**
* fetch the group data from group table
*
* @access public
* @param array $fields fields to get
* @param array $clause params to identify the group
* @return array $data data of the group
*/

Even with that code I am not sure exactly why you are getting the error. You might want to e-mail the person that wrote the code at melonfire@mail.com to see if they can be of more help.

I'm having the same trouble. However, even without using the getGroups function, I still get an error with the addUser function once the form is submitted (same error: Fatal error: Call to a member function on a non-object) .

Hello,

We'll try to reproduce this and get back with a fix. Please give us a couple of days.

Thanks!


Originally posted by nooboy
In the illustration at http://www.devshed.com/Server_Side/PHP/patUser/patUser2/page12.html the groups field won't display and when I view the source I get the following:

<select name="gid[]" multiple>
<br>
<b>Fatal error</b>: Call to a member function on a non-object in <b>/include/patUser.php</b> on line <b>2035</b><br>


Any ideas?

I noticed one error in the script in the way it has been printed. This line:

// connect patUser to database/template engines $u->setAuthDbc($db);

is actualy two lines:

// connect patUser to database/template engines
$u->setAuthDbc($db);

Could that be why? Maybe because of the error in display, PHP is treating the call to setAuthDbc() as a comment and not executing it...leading to problems later down? Can you try that and see if that fixes it?

Still nothing. In fact, the script completely freezes once it hits the getGroups function.. (The submit button is not shown) , however, if the getGroups is omitted, the submit button is shown.. it still doesn't matter due to the fact that as soon as you hit submit, the addUser function displays the same error.

We're unable to understand why you're getting this error, the code works fine as is out here, with zero errors. Maybe you should check that he database is up and the password etc is correct?

what version of php are you guys ussing maybe that is the issue?

Posted by: Anonymous User
Subject: Chapter titles
Date: 05-07-2003 07:51:56 MST

This is not specific to this article, but this article is the one that finally made me want to post this:

I like your PHP articles very much in general. In fact they have helped me a lot in the past. However, your chapter titles make it extremely difficult to use the tutorials as a reference. If I'm looking for a specific bit in a tutorial I have read some time ago, chapter titles like "Meet the family" force me to skim through the whole article to find what I need, even when it is already oranized into topics. No doubt, the creative naming makes reading more fun. But I think quick acces is more important here.

Otherwise, great article as always!

Posted by: LANLord (http://forums.devshed.com/member.php?s=&action=getinfo&userid=19788)
Subject: Database Schema
Date: 05-06-2003 08:31:58 MST

The database schema that patUser uses is a pretty common one, but I think it's a bit clunky to have three tables, users, groups and a user/group table.

I'm working on my own system with only a user table and a group table. I give the groups an ID that is a power of two, ie: 1, 2, 4, 8, 16, etc. What I do is put a group ID field on the user record. If a user is in groups 1 and 16, then that user's group ID is set to 17. I just do logical ANDs on the two tables to get the info I need.

Unfortunately, I only get 29 distinct IDs in an integer field, but I'm planning on experimenting with a VARCHAR field to see what I can get.

Posted by: Anonymous User
Date: 05-07-2003 12:29:22 MST

I like that idea. I was working on a setup where user ID's are stored in one of the fields in the group database. Each ID is seporated by a comma. Then I just explode the field when I need to see if a user is in a group.

It would work the other way as well, storing the users groups in a single field with commas.

If you would like to see an article covering a particular topic, please post your request here (http://forums.devshed.com/forumdisplay.php?s=&forumid=65).

md_doc: I'm using php 4.1.1

What version was this coded on?










privacy (GDPR)