public function get_type($field, $value)
 {
     return $this->db->select(parent::table_name() . '.*')->select(STREAMS_TABLE . '.stream_name, ' . STREAMS_TABLE . '.stream_slug, ' . STREAMS_TABLE . '.stream_namespace, ' . STREAMS_TABLE . '.about')->select('(SELECT COUNT(*) FROM ' . $this->db->dbprefix('calendar') . ' WHERE item_type = ' . $this->db->dbprefix('calendar_item_types') . '.id ) AS total_items')->join(STREAMS_TABLE, 'stream_id = ' . STREAMS_TABLE . '.id', 'left')->where($field, $value)->limit(1)->get(parent::table_name())->row();
 }
 public function get_categories()
 {
     return $this->db->select('*')->select('(SELECT COUNT(*) FROM ' . $this->db->dbprefix('calendar') . ' WHERE category = ' . $this->db->dbprefix('calendar_categories') . '.id ) AS total_items')->order_by('name', 'ASC')->get(parent::table_name())->result();
 }
Exemple #3
0
 public function entries($start = null, $end = null, $categories = false)
 {
     if ($start != null && $end != null) {
         $sql = "    SELECT " . parent::table_name() . ".*,\n                        " . $this->db->dbprefix('calendar_item_types') . ".stream_id, " . $this->db->dbprefix('calendar_item_types') . ".admin_layout,\n                        " . $this->db->dbprefix('calendar_categories') . ".item_color\n                        FROM " . parent::table_name() . "\n                        LEFT JOIN " . $this->db->dbprefix('calendar_item_types') . " ON item_type = " . $this->db->dbprefix('calendar_item_types') . ".id\n                        LEFT JOIN " . $this->db->dbprefix('calendar_categories') . " ON category = " . $this->db->dbprefix('calendar_categories') . ".id\n                        WHERE (\n                            (DATE_FORMAT(date_start, '%Y-%m-%d') >= '" . date('Y-m-d', $start) . "' AND DATE_FORMAT(date_end, '%Y-%m-%d') <= '" . date('Y-m-d', $end) . "' AND recurrence = 'once')\n                        OR  (DATE_FORMAT(date_start, '%Y-%m-%d') <= '" . date('Y-m-d', $end) . "' AND recurrence <> 'once')\n                        )\n                        " . ($categories !== false ? 'AND category IN (\'' . @implode("', '", $categories) . '\')' : '') . "\n                        ";
         return $this->db->query($sql)->result();
     }
     return null;
 }