<?php
include_once 'logging.php';

class Post {
 // DB stuff
    private $conn;
    private $table = 'events2';
// Post Properties
    public $id;
    public $title;
    public $allDay;
    public $ev_start;
    public $ev_end;
    public $details;
    public $event_url;
    public $venue;
    public $venue_add;
    public $social_url;
    public $sponsors;
    public $textColor;
    public $borderColor;
    public $backgroundColor;
///////////////////////////////////////////////////
// Constructor with DB
    public function __construct($db) {
        $this->conn = $db;
      }
//////////////////////////////////////////////////////
// get data
    public function read() {
// Create query
      $sql = 'SELECT id, title, allDay, ev_start, ev_end, details, event_url, venue, venue_add, social_url,sponsors,textColor,borderColor,backgroundColor FROM ' . $this->table . ' ORDER BY ev_start ' ;
      _log('Post Query:'.$sql);
// Prepare statement
      $stmt = $this->conn->prepare($sql);
// Execute query
      $stmt->execute();
      return $stmt;
    }
///////////////////////////////////////////////////////////
// get record count
  	  public function thecount() {
// Create query
    	  $query = 'SELECT COUNT(*) FROM ' . $this->table ;
// Prepare statement
      $stmt = $this->conn->prepare($query);
// Execute query
      $stmt->execute();
      return $stmt;
 	   }
}

?>