Welcome Guest, Not a member yet? Register   Sign In
load helpers and libraries version difference
#1

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

[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
#3

[eluser]dadamssg87[/eluser]
love you
#4

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

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




Theme © iAndrew 2016 - Forum software by © MyBB