User DbObject and the Auth class

38 views
Skip to first unread message

Peter

unread,
Sep 25, 2011, 3:38:00 AM9/25/11
to Simple PHP Framework
Im trying to learn more about php by using this framework but running
into a little trouble on understanding how some of this stuff works
and why.

So I have a situation where I want users to be able to edit their
information and update it. This is information like first_name,
last_name, gender, contact_phone, contact_mobile, address, suburb,
city, post_code.

Now I thought best practice would be to use a DbObject User class and
then use the object on the information edit page like so:
$user = new User($Auth->id);

Giving me the ability to echo out the users current details into a
form like so:
echo $user->first_name etc etc.

However I have noticed that the Auth Class already creates the user
object and puts it into $Auth->user;

Why is the Auth Class doing this? Doesn't that mean the Auth class is
adding an extra query to the user database on every page?

Instead should I be using echo $Auth->user->first_name etc etc?

Help in understanding is very much appreciated.
Im also new to the idea of DbObjects and dont have a great
understanding on the purpose apart from the idea of abstraction.

Tyler Hall

unread,
Sep 25, 2011, 9:45:02 AM9/25/11
to simple-php...@googlegroups.com
Hi, Peter.

You're correct. The Auth class automatically instantiates a User
object for you. It's just there for your convenience.

Tyler

> --
> You received this message because you are subscribed to the Google Groups "Simple PHP Framework" group.
> To post to this group, send email to simple-php...@googlegroups.com.
> To unsubscribe from this group, send email to simple-php-frame...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-php-framework?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages