CodeIgniter Forums

Full Version: load helpers and libraries version difference
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]dadamssg87[/eluser]
Hi all,

I developed in codeigniter a while back and am starting a new project. I downloaded the new version and already having trouble with the changes. I'm sure they're subtle i just can't seem to get a few things working. For example, i would like to load helpers, libraries, and the database, in the parent::Controller();. This is what did work on the old version

Code:
class Register extends Controller {

    function Register()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
        $this->load->library('session');
        $this->load->library('form_validation');
        $this->load->database();
        $this->load->model('user_model');    
    }

and know "Controller" has now become "CI_Controller" and have also noticed on the "welcome" controller codeigniter comes with uses "public function index()" instead of just "function index()".

How the heck do you load your helpers and libraries at the start to use in all your controller functions?

El Forum

[eluser]danmontgomery[/eluser]
Code:
class Register extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->library('session');
        // etc
    }
}

http://php.net/manual/en/language.oop5.decon.php
http://www.php.net/manual/en/language.oo...bility.php
http://ellislab.com/codeigniter/user-gui...odels.html

etc

El Forum

[eluser]dadamssg87[/eluser]
love you

El Forum

[eluser]InsiteFX[/eluser]
Also all Models need to be changed to CI_Model

El Forum

[eluser]osci[/eluser]
Excellent place to check for upgrading issues and info is userguide - upgrading