I consider myself a fairly competent PHP programmer. I have a decent concept of Object Oriented Programming (putting into practice is a different story), but with this new problem, I'm beginning to go bonkers:
Everyone knows the easiest way to start OO database work is to create a database object that actually performs the queries etc. PEAR:
B does this, and I wrote my own that will interface with MySQL and PostgreSQL. Methods like setQuery(), Query() and getNumRows() are present.
So the next step: Every row in a certain table is used as an object. There are private variables corresponding to each field in the table to which the object belongs with public methods to access them. Easy enough hmm?
PHP cannot know my table schema (unless there is a way, please tell me), so I am forced to make a discrete object for every one of them. Sure I can make a generic "table" object, but I still have to name that table and put its fields into some sort of array for the queries to be populated properly. That's where I fall into a trap: I want to decrease the amount of typing and programming I have to do, but it looks as though this is almost impossible.
So what happens when I put JOINS into the mix? How do I handle those properly with objects? How would I properly have two table objects and still be able to define the relationship between them so that the actual database query might go smoothly?
I think I may just go back to procedural programming.
I'm pulling my hair out... help!
Wes