Update status board classes to use new DatabaseObject base
Updated schema to include new views
This commit is contained in:
@@ -1,83 +1,14 @@
|
||||
<?php
|
||||
|
||||
class StatusBoard_IncidentStatus {
|
||||
class StatusBoard_IncidentStatus extends StatusBoard_DatabaseObject {
|
||||
|
||||
protected static $table = 'incidentstatus';
|
||||
|
||||
protected $id;
|
||||
protected $incident;
|
||||
protected $status;
|
||||
protected $ctime;
|
||||
|
||||
protected function __construct($id, $incident, $status, $ctime) {
|
||||
$this->id = $id;
|
||||
$this->incident = $incident;
|
||||
$this->status = $status;
|
||||
$this->ctime = $ctime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an Incident object given its ID
|
||||
*
|
||||
* @param int $id
|
||||
* @return StatusBoard_Incident
|
||||
*/
|
||||
public static function fromId($id) {
|
||||
$database = StatusBoard_Main::instance()->database();
|
||||
|
||||
$incident_status = self::fromDatabaseRow(
|
||||
$database->selectOne('SELECT * FROM `incidentstatus` WHERE id=:id', array(
|
||||
array('name' => 'id', 'value' => $id, 'type' => PDO::PARAM_INT)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $incident_status;
|
||||
}
|
||||
|
||||
protected function create() {
|
||||
$database = StatusBoard_Main::instance()->database();
|
||||
$database->insert(
|
||||
'INSERT INTO `incidentstatus`
|
||||
(`id`, `incident`, `status`, `ctime`)
|
||||
VALUES(NULL, :incident, :status, :ctime)',
|
||||
array(
|
||||
array('name' => 'incident', 'value' => $this->incident, 'type' => PDO::PARAM_INT),
|
||||
array('name' => 'status', 'value' => $this->status, 'type' => PDO::PARAM_STR),
|
||||
array('name' => 'ctime', 'value' => $this->ctime, 'type' => PDO::PARAM_STR),
|
||||
)
|
||||
);
|
||||
|
||||
$this->id = $database->lastInsertId();
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
$database = StatusBoard_Main::instance()->database();
|
||||
$database->update(
|
||||
'DELETE FROM `incidentstatus` WHERE `id`=:id LIMIT 1',
|
||||
array(
|
||||
array('name' => 'id', 'value' => $this->id, 'type' => PDO::PARAM_INT),
|
||||
)
|
||||
);
|
||||
|
||||
$this->id = null;
|
||||
}
|
||||
|
||||
public function id() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function incident() {
|
||||
return $this->incident;
|
||||
}
|
||||
|
||||
public function status() {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function ctime() {
|
||||
return $this->ctime;
|
||||
}
|
||||
|
||||
|
||||
protected $_db_id;
|
||||
protected $_db_incident;
|
||||
protected $_db_status;
|
||||
protected $_db_ctime;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user