DB_DataObject and OOP
Date: 03/22/06
(PHP Community) Keywords: php, html, database, asp, sql
Ok - I'm going to try my best to not sound like I have no idea what I'm talking about -
I'm trying to move more towards pure OOP practices in my PHP projects, and I've been sifting through a couple of packaged MVC frameworks and some OnLAMP tutorials on writing you're own... very cool stuff, too bad i'm only like 3 years behind...
anyway - I use DB_DataObject primarily for my database interactions (if you don't know DB_DataObject is an object relational database tool with an automatic class generating script) - I _would_ like to be able to do some things easier/better with DB_DataObject (PK+FK JOINs in particular could be a bit more elegant) but overall it's a useful tool that cuts out a lot of SQL coding...
So - my actual question - in the article I'm digging thru (http://www.onlamp.com/pub/a/php/2005/09/15/mvc_intro.html) the author is extending his base framework class with a framework DB class that provides the database connection (it's basically a tiny class that sets $this->db) - I'm wondering what is the best way to incorporate DB_DataObject into a solid OOP class schema
- should I use the DataObject generated class as my base class that I extend - then what if I'm writing a class that doesn't need DB connectivity? The other thing I was thinking was to attach it to my other classes like $this->DO = new DataObject_Class but I really like having my class properties line up with my database fields (user.email = $user->email _not_ $user->DO->email); Is there something I'd be better off using the DB_DataObject (I can't bear the thought of -gasp- writing SQL anymore)
I'm somewhat new to this OOP game so any help is appreciated
Source: http://community.livejournal.com/php/429624.html