Location: PHPKode > projects > ConCentric Event Planning Software > CC/system/application/models/rooms_model.php
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * MODULE NAME   : rooms_model.php
 *
 * DESCRIPTION   : rooms model
 *
 * MODIFICATION HISTORY
 *   V1.0   2008-10-31 11:47 PM   - Leane Verhulst     - Created
 *
 * @package			ConCentric
 * @subpackage		rooms model component Class
 * @author			Leane Verhulst
 * @copyright		Copyright (c) 2008
 * @license			http://www.gnu.org/licenses/gpl.html
 */
class Rooms_model extends base_model
{

	function Rooms_model()
	{
		parent::Base_model();

		$this->_TABLES = array('rooms' => $this->config->item('concentric_table_prefix') . 'rooms',
								'colors' => $this->config->item('concentric_table_prefix') . 'colors');

		// Cache to store already fetched items
		$this->_CACHE = array();

	}

	function fetchRooms()
	{
		// Build a query to get the data
		$this->db->select('room.id, room.name, room.alternateName, room.capacity, room.sortOrder, room.publicQ, color.id AS color_id, color.name AS color_name, color.htmlCode AS color_htmlCode');
		$this->db->from($this->_TABLES['rooms'] . ' room');
		$this->db->join($this->_TABLES['colors'] . ' color', 'color.id = room.colorID', 'left');
		$this->db->order_by('room.sortOrder ASC');
		$query = $this->db->get();
		return $query;
	}

	function fetchRoomColor($roomID = '')
	{
		if ($roomID == '')
			return FALSE;
		
		$data = '';
		$this->db->select('color.htmlCode');
		$this->db->from($this->_TABLES['rooms'] . ' room');
		$this->db->where('room.id = ' . $roomID);
		$this->db->join($this->_TABLES['colors'] . ' color', 'color.id = room.colorID', 'left');
		$query = $this->db->get();
		if ($query->num_rows() > 0)
		{
			$row = $query->row_array();
			$data = $row['name'];
		}

		return $data;
	}

	function fetchRoomName($roomID = '')
	{
		if ($roomID == '')
			return FALSE;
		
		$data = '';
		$this->db->select('name');
		$this->db->from($this->_TABLES['rooms'] . ' room');
		$this->db->where('room.id = ' . $roomID);
		$query = $this->db->get();
		if ($query->num_rows() > 0)
		{
			$row = $query->row_array();
			$data = $row['name'];
		}
		//else
		//{
		//	flashMsg('info','What?');
		//}

		return $data;
	}

}



/* End of file rooms_model.php */
/* Location: ./system/application/models/rooms_model.php */
Return current item: ConCentric Event Planning Software