<?php

$board = new MessageBoard();
$board->go();
class MessageBoard
{
    protected $db;
    protected $form_errors = array();
    protected $inTransaction = false;
    public function __construct()
    {
        set_exception_handler(array($this, 'logAndDie'));
        $this->db = new PDO('sqlite:/tmp/message.db');
        $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }
    public function go()
    {
        // The value of $_REQUEST['cmd'] tells us what to do
        $cmd = isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show';
        switch ($cmd) {
            case 'read':
                // read an individual message
                $this->read();
                break;
            case 'post':
                // display the form to post a message
                $this->post();
                break;
            case 'save':
                // save a posted message
                if ($this->valid()) {