All pastes #636991 Raw Edit

Something

public text v1 · immutable
#636991 ·published 2007-07-28 12:38 UTC
rendered paste body
class Intraface_TableGateway extends pdoext_TableGateway
{
    private $user;

    function __construct($table, $conn, $user)
    {
        $this->user = $user;
        parent::__construct($table, $conn);
    }

    function insert($data)
    {
        $data['intranet_id'] = $this->user->getActiveIntranetId();
        $data['user_id'] = $this->user->getId();
        parent::insert($data);
    }

    function update($data, $condition)
    {
        $condition['intranet_id'] = $this->user->getActiveIntranetId();
        $condition['user_id'] = $this->user->getId();
        parent::update($data, $condition);
    }

    function delete($condition)
    {
        $condition['intranet_id'] = $this->user->getActiveIntranetId();
        $condition['user_id'] = $this->user->getId();
        parent::delete($condition);
    }
}

class Ticket_TableGateway extends Intraface_TableGateway
{
    function __construct($conn, $user)
    {
        parent::__construct('ticket', $conn, $user);
    }

    function getFromId($id)
    {
        $result = parent::fecth($id);
        return new Ticket($result);
    }
}

$gateway = new Ticket_TableGateway($conn, $user);
$ticket = $gateway->getFromId($id);

class Ticket {
     function __construct($result)
     {
          // loop through the result and set Ticket variables
     }
}