Problem with database queries |
[eluser]Olivier M.[/eluser]
Hi everybody... I try to make a small application. I have written a small librairy : Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); But it doesn't work and I don't know why because the same code works in a controller (without CI) : Code: <?php So my questions : - someone can help me ??? - why we must use "$this->CI" in a library ?
[eluser]crumpet[/eluser]
$CI =& get_instance(); neeeds to be $this->CI =& get_instance();
[eluser]Michael Wales[/eluser]
Because you want to assign the class variable to the returned value of get_instance(). Your current code is assigned a method variable to that return value - PHP's scoping only allows this value to be accessible from within the same method (unless passed as a parameter). The class variable is scoped to be accessible from the entire class. PHP.net: Variable Scope
|
Welcome Guest, Not a member yet? Register Sign In |