I think your mising the point. I use classes to create more modular code, I
find it keeps my code structured and easy to modify for other sites. I can
have a class for one site, I can then copy that class and easily modify it
to suit for another site. I do not use my classes for storeing data (ie.
with sessions) its just an interface for the db. classes allow you to break
your code up, make it more modular (not to say you cant without classes, I
just find it easier)
[dcf]
- display
- control
- function
my display is my html front end. my function is my class with all my
functions, variables, etc related to that one task. my control links my
display to my function. its an interesting way of programming that I find
quite simple.
because all three parts are seperate I find the html guys can go in and play
with html, modify it all they want, even if they want to add a new feature
to that page (that they know is in the class) they can easily modify the
control todo this without any real knowlage of what the function does, all
they need to know is that it does do it. not how.
you can read more about this in various ms books, 'rapid development' is the
one I read first.
start using classes as a way of modularizing your code, insted of combining
it with sessions to store data, and you will see how this all fits in :)
you can store a class(its data) in sessions, but I rarley need this, I use
it for my cart (product_id, product_quan), but I dont use it for anything I
want perminently stored, that all goes in the database. sessions are handy
for storeing unique id numbers to identiy what customer is who. you can
store massive stuff in there, I wouldnt, databases are more reliable and
work better for this purpose. thats what databases are for.
--
Chris Lee
[EMAIL PROTECTED]
""Chris Kovalcik"" <[EMAIL PROTECTED]> wrote in message
029501c0e2fe$a2aed030$01c8c8c8@ibcserver">news:029501c0e2fe$a2aed030$01c8c8c8@ibcserver...
Hi,
Can a class be stored as a session variable?
If not, what advantage is there to using classes in php?
I kind of see classes as used for things that will be frequently
accessed/stored in memory, but with php(web) the code is basically executed
once with nothing remaining in memory. Seems kind of a pain to create a
class, initialize the class and work with it all for a single execution, or
am I missing something?
EX: I create a customer class, then I have to fill in all the member
variables, etc. But I would have to store all the info in a DB anyways, so
what point is there to the class if I just need to update the DB. I can see
a class for the DB access it self, to make it easier to change to other
DB's, but not for a customer.
Chris
--
PHP General 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]