[eluser]the_unforgiven[/eluser]
I have this in my model:
Code:
function getLeft(){
$query = $this->db->select('id', 'title', 'created_on');
$query = $this->db->where('published', 'active');
$query = $this->db->get('mcd_events');
return $query->result();
}
Or am i getting mixed up between the two, what should I have in the controller and model then? Just to point out if am on the right tracks.
Full Controller File
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Events extends Controller {
function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->model('Eventsmodel');
$this->config->load('mcd');
}
function index() {
// Get UL list for navigation
$data['events'] = $this->Eventsmodel->getLeft();
//$controller = $this->uri->segment(1);
//$data['events'] = $this->Eventsmodel->getLeft($controller);
$this->load->view('events', $data);
}
function getDetails($id = null) {
if($id != null){
$data['mainContents'] = $this->Eventsmodel->getRightDetails($id);
}
$this->load->view('events', $data);
$controller = $this->uri->segment(1);
$data['events'] = $this->Eventsmodel->getRHSDetails(2);
$this->load->view($controller, $data);
}
}
/* End of file events.php */
/* Location: ./application/controllers/events.php */
Full Model File
Code:
<?php
class Eventsmodel extends Model {
function __construct()
{
parent::__construct();
// load database class and connect to MySQL
$this->load->database();
}
function getLeft(){
$query = $this->db->select('id', 'title', 'created_on');
$query = $this->db->where('published', 'active');
$query = $this->db->get('mcd_events');
return $query->result();
}
function getRightDetails($id){
$qs = "SELECT description FROM mcd_events WHERE id=$id";
$this->load->view('events');
}
function getRHSDetails($id){
if($id){
$this->Eventsmodel->getRightDetails($id);
$this->load->view('events');
}
}
}
?>