Welcome Guest, Not a member yet? Register   Sign In
There's limit for loaded libraries?
#1

[eluser]Unknown[/eluser]
Hello,
I'm with a big problem, I have a controller managing all "profile user"(e.g.: save, update,...) and this controller loads 3 models and 3 libraries inside the constructor.

The problem is: When I load a new library in some function of this class the system returns this error(independent of which class I want to load) :

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Perfil::$Upload

Filename: controllers/perfil.php

Line Number: 204

If I load the library in "autoload.php" it works, but I can't load all libraries there... I have no idea what is happening.

the constructor:
Code:
public function __construct()
  {
    parent::__construct();
    $this->load->helper('form');
           $this->load->model('perfil_model');
           $this->load->model('cidades_model');
           $this->load->model('uf_model');
            
           $this->load->library('image_lib');
    $this->load->library('form_validation');
           $this->load->library('loginverifica');        
          
           $this->loginverifica->check_isvalidated();      
  }


This is a bug or some problem with my code?
Can someone help me?

Thanks
#2

[eluser]Unknown[/eluser]
Try with:
$this->load->library(array('lib1','lib2','libN'));

I don't know what cause the problem, but I think everything is gonna be alright with this code
#3

[eluser]Unknown[/eluser]
Hi Plamba95, I've tried it and didn't works. But you with this give an idea and I found the issue.

I created my own library like this:
Code:
class LoginVerifica extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->helper('form');
}

  public function check_isvalidated(){
   if(! $this->session->userdata('validated')){
    redirect('login');
   }
  }
}

I read this documentation:
http://ellislab.com/codeigniter/user-gui...aries.html

and I saw my mistake, my class was extending to "controller" and had a constructor, I've changed to this:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class LoginVerifica {



  public function check_isvalidated(){
                $CI =& get_instance();
  $CI->load->helper('form');
   if(! $CI->session->userdata('validated')){
    redirect('login');
   }
  }
}

And now it's working loading multiple libraries.

Thanks Smile
#4

[eluser]InsiteFX[/eluser]
Try adding this to your Constructor affter everything else:
Code:
parent::__construct();
#5

[eluser]Aken[/eluser]
parent::__construct() should be first.




Theme © iAndrew 2016 - Forum software by © MyBB