[eluser]Saoshyant[/eluser]
Hi, very much new to CI and MVC in general. I'm building a simple website to learn the framework, but even after going through the tutorial twice, I seem to have hit a wall.
I have a complex menu present in every page, which is built using categories and subcategories, so, if I understand correctly, I should create a library to do this and load it in every controller that needs it.
Code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Menus {
function alist() {
$CI =& get_instance();
$query = $CI->db->query('QUERY');
return $query->row_array();
}
}
?>
Then load it in one of the controllers:
Code:
$this->load->library('Menus');
$testing = $this->menus->alist();
print_r($testing);
I don't know if this is the right way of doing it. Worse, I can't seem to use db->query() even though I'm in theory following the steps in the user guide. Help?