Welcome Guest, Not a member yet? Register   Sign In
Shouldn't $this->load->library('foo') return TRUE if loaded?
#1

[eluser]stormbytes[/eluser]
Baffling.

I'm loading a library in an if/elseif block, within a form validation callback function, like so:

Code:
...
elseif( ! $this->load->library('resource', $resource_url))
    {...

I'm debugging it with Netbeans/Xdebug and I *see* the library loading/executing its constructor successfully. But for some reason, it's not returning TRUE??

Huh??
#2

[eluser]Phil Sturgeon[/eluser]
The loader returns nothing, it assigns it to $this->resource. And CONSTRUCTORS ONLY TAKE ARRAYS. We've been through this all before Smile
#3

[eluser]stormbytes[/eluser]
Yes yes I'm aware. I re-wrote the constructor to take an array. If the constructor 'returns FALSE' then shouldn't the load call fail?

EDIT: Just read your reply in the other thread. Thanks for shedding some light.

Whats your advice Phil? How would I best go about accomplishing what I'm trying to do here? I need to know if the constructor succeeds or fails, based on the param that I'm passing to it.
#4

[eluser]Phil Sturgeon[/eluser]
Nope. Everything is in here dude:

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

You just load a library, assign it to the super-instance ($this) then call it. That is it.
#5

[eluser]stormbytes[/eluser]
Damn.. a part of the UG that I actually haven't read! Hah Tongue

Thanks Phil -

I'll refactor.... ughhhhhh
#6

[eluser]Phil Sturgeon[/eluser]
Code:
$this->load->library('resource', array('url' => $resource_url));

if ($this->resource->is_valid())
{
    // do stuff
}

or sod the constructors:

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

if ($this->resource->is_valid($resource_url))
{
    // do stuff
}




Theme © iAndrew 2016 - Forum software by © MyBB