CodeIgniter Forums
Problem with a driver - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Problem with a driver (/showthread.php?tid=54043)



Problem with a driver - El Forum - 08-20-2012

[eluser]Unknown[/eluser]
Hi guys!

I'm trying to write my first CI driver, but I'm experiencing some problems with it... . It doesn't matter what I do, I always get the message that ci is unable to load the requested driver... .

Here is the file structure:
/application
/libraries
/DataObjectWrapper
DataObjectWrapper_customer_dow
DataObjectWrapper
Here is the constructor from my driver:
Code:
class DataObjectWrapper extends CI_Driver_Library implements do_wrapper
{
    protected $valid_drivers;
    protected $CI;

    /* @var $data_object DataObject */
    protected $data_object;
    /* @var $db DB */
    protected $db;

    public function __construct(Array $params)
    {
        $this->valid_drivers = array('dataobjectwrapper_customer_dow');
        $this->data_object = $params[0];
        $this->db = $params[1];
    }
}

And here is the child:
Code:
class Customer_DOW extends CI_Driver
{

    public function hi()
    {
        echo 'hi';
    }
}

Can somebody please tell me, whats going on?


Problem with a driver - El Forum - 08-22-2012

[eluser]Unknown[/eluser]
I think I know what the problem is.
I load the driver these way:
Code:
$this->load->driver('DataObjectWrapper',array($customer, $db));
$this->dataobjectwrapper->customer_dow->hi();
I can't load the driver with parameters. Afaik, the second parameter from the driver Method tells CI which childs to load.

But I need to give these parameters to my object. How can I do this?