<p>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.</p>

<p>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.  </p>

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

<p><strong>Edit:</strong> 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.</p>

[{'answer_id': 22284, 'author': 'dragonmantank', 'author_id': 204, 'author_profile': 'https://Stackoverflow.com/users/204', 'pm_score': 2, 'selected': False, 'text': '<p>Take a look at the <a href="http://framework.zend.com" rel="nofollow noreferrer">Zend Framework</a>, 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.</p>\n'}, {'answer_id': 22298, 'author': 'Anders Sandvig', 'author_id': 1709, 'author_profile': 'https://Stackoverflow.com/users/1709', 'pm_score': 2, 'selected': False, 'text': '<p>Maybe <a href="http://www.phpdoctrine.org/" rel="nofollow noreferrer">Doctrine</a> would do the job? It seems to be inspired by <a href="http://www.hibernate.org/" rel="nofollow noreferrer">Hibernate</a>.</p>\n'}, {'answer_id': 22304, 'author': 'rix0rrr', 'author_id': 2474, 'author_profile': 'https://Stackoverflow.com/users/2474', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://en.wikipedia.org/wiki/Active_record_pattern" rel="nofollow noreferrer">ActiveRecord</a> seems to be the state of the art at the moment. I can\'t recommend any good PHP frameworks for that though. I tried <a href="http://propel.phpdb.org/" rel="nofollow noreferrer">Propel</a> which, while nice, is not easy to set up (especially on a host that you can\'t install anything on).</p>\n\n<p>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.</p>\n'}, {'answer_id': 22330, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p><a href="https://stackoverflow.com/questions/22278/whats-a-good-way-to-encapsulate-data-access-with-php-mysql/22304#22304">rix0rrr hit on it a bit</a>, 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 <a href="http://greaterscope.net/projects/dbFacile" rel="nofollow noreferrer">dbFacile</a></p>\n\n<p>I also wrote a bit of a <a href="http://greaterscope.net/documentation/php_database_abstraction_class_comparison.html" rel="nofollow noreferrer">usage comparison</a> of the tools I found a few years ago. It\'s incomplete, but might give you a good starting point.</p>\n\n<p>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 <a href="http://greaterscope.net/projects/ORMer" rel="nofollow noreferrer">ORM project</a> that aims to require minimal setup and great ease of use.</p>\n\n<p>The only requirement for my projects is PHP5.</p>\n'}, {'answer_id': 22510, 'author': 'Christian Lescuyer', 'author_id': 341, 'author_profile': 'https://Stackoverflow.com/users/341', 'pm_score': 1, 'selected': False, 'text': '<p>I would try a framework. <em>Zend Framework</em> has been cited. <a href="http://www.symfony-project.org/" rel="nofollow noreferrer">Symfony</a> seems interesting. It\'s based on ideas from <em>Ruby on Rails</em>.</p>\n'}, {'answer_id': 26828, 'author': 'Scott Gottreu', 'author_id': 2863, 'author_profile': 'https://Stackoverflow.com/users/2863', 'pm_score': 1, 'selected': False, 'text': '<p>You could also take a look at Prado.  <a href="http://www.pradosoft.com/" rel="nofollow noreferrer">http://www.pradosoft.com/</a>  It uses Active Record and DAO.  Also if you use .Net then some of the formatting and conventions are similar.</p>\n'}]
['https://Stackoverflow.com/questions/22278', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1219/']