
PHP Design - Biggest Database Oversights - ajbatac
http://www.justincarmony.com/blog/2008/10/25/php-design-biggest-database-oversights/
======
edb
These problems have been solved by the various popular php-based MVC
frameworks. My favourite is <http://www.cakephp.org/>, but I hear a lot of
good things about <http://codeigniter.com/> as well.

~~~
liuliu
Recently I played with Django+Python. One thing I found difficult with MVC
frameworks is how to make memcached for per query more comfortable. Contrary,
hand coded oo interface can handle that well. (You can always hand code
memcached layer in your own model with MVC framework of course, but here I am
arguing that framework should have a universal way to make the utility of
memcached invisible)

------
k4st
As I commented on the blog, he fell into the trap of needlessly looping over
sets of data.

1) Loop over MySQL result set in GetArray

2) Loop over array of results to format them in GetVideos

3) assumed loop over results to eventually display them to the user.

All three steps could be accomplished at the same time by simply using
iterators.

~~~
jayair
could you give me a quick example of this?

~~~
k4st
Yes! I'm copying and pasting some code from various areas.

Here is an old and slightly modified mysql result set iterator that fits the
purposed of the newer code that makes this example nice:
<http://codepad.org/nmD4pDES>

Here is a windowing iterator, it gives the person the ability to shift and pop
elements from the inner iterator, thus narrowing the field that the iterator
goes over: <http://codepad.org/IsE5U7cw>

We can now do the following... <http://codepad.org/nP0EEKxT>

~~~
jayair
thx, appreciate it.

------
KrisJordan
How the Recess! Framework addresses these oversights:
[http://www.krisjordan.com/2008/11/28/how-recess-solves-
commo...](http://www.krisjordan.com/2008/11/28/how-recess-solves-common-
phpmysql-issues/)

To summarize: abstractions and proper layering of database code.

------
KrisJordan
Great article. I'm writing an open source PHP framework called Recess! which
addresses these issues and an alpha release will be public in a week or so.
<http://www.recessframework.com/>

------
jsmcgd
Nice heads-up advice. Basically it could be summarized by 'Abstract, abstract
and abstract some more' or if you're a Python aficionado DRY (don't repeat
yourself).

~~~
rbanffy
I think the DRY motto came from the Rails folks.

~~~
gnaritas
It didn't, DRY is much older than Rails.

