Welcome Guest, Not a member yet? Register   Sign In
New to code igniter having a hard time with instantiating classes
#5

[eluser]danmontgomery[/eluser]
[quote author="Bart v B" date="1312863341"]ZIPPP... Wrong answer..
Your writing a helper..

Code:
<?php
function __construct()
{
   parent::__construct();
   $CI =& get_instance();
   $CI->load->library('database');
}
[/quote]

No...

Code:
function __construct()
{
    parent::__construct();
    $this->load->database();
}

There's no reason to access the CI object indirectly from a model except when trying to load another model. Also, database is loaded directly, not through library().

More to the point, helpers aren't classes, they are a collection of functions. If you are trying to include your own class that isn't a model, it should be a library, and you should be using it like any other.

Code:
$this->load->library('catalog');
$this->catalog->get_catalog();

http://ellislab.com/codeigniter/user-gui...lpers.html
http://ellislab.com/codeigniter/user-gui...aries.html


Messages In This Thread
New to code igniter having a hard time with instantiating classes - by El Forum - 08-09-2011, 08:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB