views:

410

answers:

6

Most of my experience is on the MSFT stack, but I am now working on a side project, helping someone with a personal site with cheap hosting that is built on the LAMP stack. My options for installing extras are limited, so I'm wondering about how to write my data access code without embedding raw queries in the .php files.

I like to keep things simple, even with .NET. I generally write stored procedures for everything, and I have a helper class that wraps all calls to execute procedures and return data sets. I'm not looking for a full-blown ORM, but it might be the way to go and others who view this question might be looking for that.

Remember that I'm on a $7/month GoDaddy account, so I'm limited to what's already installed in their basic package.

[Edit]

Thanks @rix0rr, @Alan, @Anders, @dragon, I will check all of those out. I edited the question to be more open to ORM solutions, since they are so popular.

+2  A: 

Take a look at the Zend Framework, specifically Zend_Db. It has a Database Abstraction layer that doesn't require anything other than the MySQLi extension to be installed and isn't a full-blown ORM model.

dragonmantank
+2  A: 

Maybe Doctrine would do the job? It seems to be inspired by Hibernate.

Anders Sandvig
+3  A: 

ActiveRecord seems to be the state of the art at the moment. I can't recommend any good PHP frameworks for that though. I tried Propel which, while nice, is not easy to set up (especially on a host that you can't install anything on).

Ultimately, I rolled my own ORM/ActiveRecord framework, which is not too much work and very instructive. I'm sure other people can recommend good PHP frameworks.

rix0rrr
+2  A: 

rix0rrr hit on it a bit, in that many tools are a pain to set up. Of course, I have my own solution to this problem that has been working quite well for the past few years. It's a project called dbFacile

I also wrote a bit of a usage comparison of the tools I found a few years ago. It's incomplete, but might give you a good starting point.

You mentioned that you don't want to embed raw queries but you don't want ORM, so I'm a bit confused about the middle ground you're hoping to find. I also have an ORM project that aims to require minimal setup and great ease of use.

The only requirement for my projects is PHP5.

A: 

I would try a framework. Zend Framework has been cited. Symfony seems interesting. It's based on ideas from Ruby on Rails.

Christian Lescuyer
A: 

You could also take a look at Prado. http://www.pradosoft.com/ It uses Active Record and DAO. Also if you use .Net then some of the formatting and conventions are similar.

Scott Gottreu