NYCPHP Meetup

NYPHP.org

[nycphp-talk] class design question

David Mintz dmintz at panix.com
Thu Jul 10 18:14:55 EDT 2003


I'm rewriting my PHP/MySQL application that manages the scheduling of
court interpreters (for our office here in the federal court downtown).
It's hideous spaghetti and I want to do it over with Smarty and Pear and
OOP.

There are entities like Judge and User and Event and Interpreter that will
merit their own objects and be persisted in the database.

Suppose you have a class User. Would you give it a save() method that
writes its state to the database? And if so, do you pass this method a
Pear $db object as argument, or does it already possess its own $db object
(which perhaps you handed it at instantiation time)?

... OR ...

Would you have write a separate DB class -- one that extends the Pear DB
perhaps -- with methods like saveXXX() for each of your classes?

I hope this is clear. These may seem naive questions to you old pros. I'm
one of those self-taught lightweight dudes and I'd love to get it more
nearly right this time around. Thanks.





---
David Mintz
http://davidmintz.org/
Email: See http://dmintzweb.com/whitelist.php first!

     "You want me to pour the beer, Frank?"



More information about the talk mailing list