title: Which database patterns (ORM, DAO, Active Record, etc.) to use for small/medium projects?
body: <p>I writing real estate web site
  with basic function for choosing and ordering realty.</p>
  
  <p>It is small/simple project, but I want to write it in way,
  so in future I, or other developers, can turn it into medium business app without rewriting it 
  from scratch.</p>
  
  <p>So what kind of patterns could you advice me to use for dealing with database?</p>
  
  <p>For now I have this:</p>
  
  <pre><code>class db_DBConnection
  {
      // basic singleton pattern here...
  }
  
  // primary class to be extende by other table DAOs
  abstract class db_Table
  {
  protected $table;
  protected $order_by;
  
  /**
   * Executes specified query with prepared statements
   * returns statement object, which can fetch data.
   * 
   * @param $sql - SQL query to execute
   * @param $params - bind values to markers through associative arrays
   */
  protected function executeQuery($sql, $params = null)
  {
      $dbh = db_DBConnection::getConnection();
      $stmt = $dbh-&gt;prepare($sql);
      // binds values to markers and executes query
      $stmt-&gt;execute($params);
      return $stmt;
  }
  
  /**
   * @param id - id of row to retrieve from database
   *
   * It sends SQL query and id to executeQuery
   * function returns associative array, representing
   * database row.
   */
  public function find($id)
  {
      $sql = 'SELECT * FROM ' . $this-&gt;table . ' WHERE id=:id LIMIT 1';
              // bind id
      $params = array( ':id' =&gt; $id );
      // execute and return associative array
      return $this-&gt;executeQuery($sql, $params)-&gt;fetch(PDO::FETCH_ASSOC);
  }
  
  public function findAll($quantity, $where)
  {
  // Returns array of
  // associative arrays of table rows :)
  // TODO: write this function
  }
  
  abstract protected function insert();
  
  abstract protected function update();
  
  abstract protected function delete();
  
      // ...
  </code></pre>