Welcome Guest, Not a member yet? Register   Sign In
[solved] I can't seem to make my library work
#1

[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?


Messages In This Thread
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 04:57 AM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 05:56 AM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 06:16 AM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 06:37 AM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 07:32 AM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 07:56 AM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 05:30 PM
[solved] I can't seem to make my library work - by El Forum - 02-17-2012, 07:30 PM
[solved] I can't seem to make my library work - by El Forum - 02-18-2012, 02:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB