You are here: Re: need a pointer on OOP with php « PHP Programming Language « IT news, forums, messages
Re: need a pointer on OOP with php

Posted by nephish on 08/08/06 02:08

Ok, well what i have been doing is creating session variables for
everything possible that relates to what one may call an object (not in
the code, but at the site)
like $name = $_SESSION['name'];
$email = $_SESSION['email'];
$phone = yadda, yadda, yadda

so, i suppose this is still the easier way to pull this off.
thanks for all the info, i am trying to learn as much as possible
because i want to redesign everything in the fall. i started learning
php about a year ago, and a whole lot of stuff i did last Fall, i would
do differently this Fall.
So i want to make it as streamlined as possible.

thanks for all your help

shawn



Henk Verhoeven wrote:
> nephish wrote:
> > if i create a customer object when say, someone logs into the site. Can
> > i pass that object to each page in session variables ? like from the
> > login page, can the user move about the site without me coding the
> > declarations over and over ?
> >
> > or is there a better way to go about this ?
>
> Hi nephish,
>
> Theoretically you store objects that should have the same lifetime or
> shorter as the session in the session. Object that have a longer
> lifetime, or have to be shared by multiple users you better store in in
> a database. This is called 'persistency'. For more info on persistency
> see
> http://www-128.ibm.com/developerworks/opensource/library/os-php-flexobj/?ca=dgr-lnxw01DynamicPHP
> http://www.onlamp.com/pub/a/php/2005/06/16/overloading.html
> The thread "PHP Dynamic Database Code" started by josh.kuo@gmail.com on
> Fri, 9 Jun 2006 23:13:21 +0000 (UTC) (from which i have the above urls)
> may also be interesting.
>
> Saving objects in the session in practice has often brougt me troubles.
> The point is you must have its class loaded before the session is
> started. This may be easy if you have only one page and one object
> class, but i usually have many of both. In my experience it is more
> reliable to copy all the objects member variables (but not the ones that
> hold objects) into an asspciative array and store the array in the
> session. When you later need the object you copy the values from the
> array back into a new object.
>
> Furthermore you could take a look at patterns. An example of a pattern
> for user interfacing can be found at:
> http://www.phppeanuts.org/site/index_php/Pagina/195
> Many more patterns are at http://c2.com/cgi-bin/wiki?DesignPatterns
> (if you get lost, try: http://c2.com/cgi-bin/wiki?search=controller )
>
> Greetings,
>
> Henk Verhoeven,
> www.phpPeanuts.org.
>
> Some OO terms and definitions:
> http://www.phppeanuts.org/site/index_php/Menu/27/What+is.html
> (contains interpretations specific to the phpPeanuts framework)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация