Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once 'dbo.php';
- include_once 'oPost.php';
- class postCMS {
- private $db;
- public function __construct()
- {
- $this->db = new dbo();
- }
- public function insert(oPost $p) {
- if(!$db->insert($p))
- throw Exception ("Problem occured during insertion of post into databse.");
- }
- /**
- * @param oPost $p
- */
- public function update(oPost $p) {
- if(($p->postID != -1) && ($p->postID != NULL)) {
- if(!$db->update($p))
- throw Exception ("Problem occured during update of post on the database.");
- }
- }
- public function delete(oPost $p) {
- if(!$db->delete($p))
- throw Exception ("Problem occured during deletion of post from the database.");
- }
- public function getByID(int $id) {
- $p = null;
- if(is_int($id)) {
- $row = $db->getByID($id);
- $p = new oPost();
- $p->populate($row);
- }
- return $p;
- }
- // Use to display a number of posts on a page.
- public function display_public(int $pID) {
- $today = getdate(time());
- $list = $db->selectMonthYear($today["mon"], $today["year"]);
- for($i=0; $i<= count($list); $i++) {
- $html = <<<HTML
- <div class="post" id="{$list[i]->postID}">
- <h1> {$list[$i]->title} </h1>
- <p class="summary">
- {$list[i]->summary}
- </p>
- {$list[i]->date}
- </div>
- HTML;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement