Welcome Guest, Not a member yet? Register   Sign In
Including non CodeIgniter scripts

I think my question/problem is similar.

I have installed an outside library which works fine except that I don't know how to pass values to it. $this->load->library() seems to allow the passing of only one value but the library I'm using will accept six values (all have good defaults).

If I just want the defaults it works fine.

How can I pass multiple values?


Quote:Passing Parameters When Initializing Your Class

In the library loading function you can dynamically pass data as an array via the second parameter and it will be passed to your class constructor:

$params = array('type' => 'large', 'color' => 'red');

$this->load->library('Someclass', $params);

If you use this feature you must set up your class constructor to expect data:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Someclass {

    function Someclass($params)
        // Do something with $params

You can also pass parameters stored in a config file. Simply create a config file named identically to the class file name and store it in your application/config/ folder. Note that if you dynamically pass parameters as described above, the config file option will not be available.

I <b>have</b> read the documentation. It doesn't work for me.

I create an array of two items which I pass as the second argument to $this->load->library() but within the class constructor func_num_args() returns 0. Shouldn't it return 1?


I found the problem. The library had been loaded in the controller so when I loaded it in the model (with the arg) the loading was ignored.

Yes... Can you post some code?

Theme © iAndrew 2016 - Forum software by © MyBB