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

[eluser]Saoshyant[/eluser]
Ah. Changing it to the following fixes the issue, by invoking the CI instances that in turn get the database functions on.

Code:
class Menus {
public function __construct()
{
  $CI =& get_instance();
  $CI->load->database();
}

function alist() {
  $CI =& get_instance();
  $query = $CI->db->query('SELECT * FROM news');
  return $query->row_array();
}
}

HOWEVER, I'm wondering if I have to do the get_instance() bit in every single function. Seems like a lot of redundancy.


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