From f08eb1640388e1f067102a22ec40c30f263d92c6 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 2 Jun 2011 16:17:25 -0700 Subject: Added user management --- htdocs/src/Source.inc.php | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 htdocs/src/Source.inc.php (limited to 'htdocs/src/Source.inc.php') diff --git a/htdocs/src/Source.inc.php b/htdocs/src/Source.inc.php new file mode 100644 index 0000000..e869d20 --- /dev/null +++ b/htdocs/src/Source.inc.php @@ -0,0 +1,78 @@ + + * + */ + +require_once "base.inc.php"; + +class Source { + private $info; + + + public function __construct($info=null) { + $this->info = $info; + } + + public static function getSources() { + $db = getDatabase(); + + $query = "SELECT * FROM source ORDER BY name"; + + $rows = $db->fetchAssocRows($query); + + $result = array(); + foreach ($rows as $row) { + $source = new Source($row); + $result[] = $source; + } + + return $result; + } + + public static function getById($id) { + $where = "id='$id'"; + + return Source::getSource($where); + } + + private static function getSource($where) { + $query = "SELECT * FROM source WHERE $where"; + + $db = getDatabase(); + + $row = $db->fetchAssocRow($query); + + if ($row) { + $source = new Source(); + $source->info = $row; + + return $source; + + } else { + return false; + } + } + + public function save() { + $db = getDatabase(); + + // TODO: Implement Save + } + + public function getId() { + return $this->info['id']; + } + + public function getName() { + return htmlspecialchars($this->info['name']); + } +} + +?> + + -- cgit v1.2.3