SQL & OOP

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
GameMusic
Forum Newbie
Posts: 24
Joined: Fri Oct 28, 2005 8:33 pm

SQL & OOP

Post by GameMusic »

How do you combine SQL & OOP design principles with PHP? Joins in particular usually involve multiple tables, which means a class corresponding to a table has to know the SQL implementation of another class corresponding to a table.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

or you can use a link class between the tables..
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Why?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: SQL & OOP

Post by McGruff »

GameMusic wrote:How do you combine SQL & OOP design principles with PHP?
That's a big subject. Patterns of Enterprise Application Architecture has a ton of information on various design patterns which you can use - and when to use them. The link provides some brief summaries but the book explains everything in more detail.
GameMusic
Forum Newbie
Posts: 24
Joined: Fri Oct 28, 2005 8:33 pm

Post by GameMusic »

or you can use a link class between the tables..
What is a link class?
Why?
I'm making a message board. There are tables for users, members, forums, topics, posts, etc. Most of the joins involve searching for data that matches a nested set tree. The main reason I want to separate SQL is because I want to be able to integrate it with CMS, galleries, etc.
That's a big subject. Patterns of Enterprise Application Architecture has a ton of information on various design patterns which you can use - and when to use them. The link provides some brief summaries but the book explains everything in more detail.
Thanks. Do any of the models in particular fit with a program that needs to use joins?

Maugrim talked about a separate data layer here. Can anybody recommend other online examples or tutorials displaying such a system in more detail?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

a link class is one that understands how to attach two or more tables together. It could be generic or specific. Often, it wil be specific and will be the interface to working with the tables involved (when appropriate). ..
User avatar
staniszczak
Forum Newbie
Posts: 13
Joined: Wed Oct 05, 2005 1:39 pm
Location: Radomsko, Poland

Post by staniszczak »

You can see it for example http://propel.phpdb.org/. It's one of many Object Relational Mapping (O/R Mapping) for PHP (Propel works only with PHP5).

Best regards,
Marcin Staniszczak
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Suggested reading and links to more.

http://phplens.com/phpeverywhere/node/view/25
User avatar
staniszczak
Forum Newbie
Posts: 13
Joined: Wed Oct 05, 2005 1:39 pm
Location: Radomsko, Poland

Post by staniszczak »

PHP have huge problem with include/require (_once and normal) files - you can check - it's one of more time expensive language constructions. It's main problem in PHP performance:-( And we must remember - PHP isn't Java (it's slow - many people thinks that Java is too slow, but it isn't true for now, Java require many memory, but today it isn't slow), but we always can work with Java (PHP / Java Integration or if we write commercial soft Zend Platform). But for fan, for studying, or if we have very speed dedicated server (or cluster with Zend Platform - it's offer for example share session information between Web Servers in a cluster) it's interested pattern.

Best regards,
Marcin Staniszczak
Post Reply