<slide title="DB Layer">

<break lines="1" />
<blurb fontsize="7em">
For each table I usually do something like this
</blurb>

<example result="0" marginright="1em" fontsize="1.5"><![CDATA[<?php
class twits extends db {
  function load($id="",$lx=-1,$ly=-1) {
    if(!self::$dbh) $this->connect();
    if(strlen($id)) {
      $id = self::$dbh->quote($id);
      $where = "WHERE id=$id";
    } else $where = "status > -1";
    if($lx!=-1) {
      $limit = "LIMIT $lx,$ly";
    } else $limit="";
    try {
      $result = self::$dbh->query("SELECT * from twits $where order by ctime desc $limit");
      $rows = $result->fetchall(PDO::FETCH_ASSOC);
    } catch (PDOException $e) {
      $this->fatal_error($e->getMessage());
    }
    if(strlen($id) && count($rows)) return $rows[0];
    return $rows;
  }
}
?>]]></example>

</slide>
