Page 1 of 1

SQL & OOP

Posted: Wed Nov 02, 2005 4:31 am
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.

Posted: Wed Nov 02, 2005 7:25 am
by feyd
or you can use a link class between the tables..

Posted: Wed Nov 02, 2005 8:10 am
by BDKR
Why?

Re: SQL & OOP

Posted: Wed Nov 02, 2005 6:51 pm
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.

Posted: Fri Nov 04, 2005 1:31 am
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?

Posted: Fri Nov 04, 2005 7:24 pm
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). ..

Posted: Wed Nov 16, 2005 2:00 am
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

Posted: Wed Nov 16, 2005 8:05 am
by BDKR
Suggested reading and links to more.

http://phplens.com/phpeverywhere/node/view/25

Posted: Wed Nov 16, 2005 11:25 am
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