blob: e2ded62e22829527a065783b0642d9b9772bbe6e [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001#########################
2Using CodeIgniter Drivers
3#########################
4
5Drivers are a special type of Library that has a parent class and any
6number of potential child classes. Child classes have access to the
7parent class, but not their siblings. Drivers provide an elegant syntax
8in your :doc:`controllers <controllers>` for libraries that benefit
9from or require being broken down into discrete classes.
10
11Drivers are found in the system/libraries folder, in their own folder
12which is identically named to the parent library class. Also inside that
13folder is a subfolder named drivers, which contains all of the possible
14child class files.
15
16To use a driver you will initialize it within a controller using the
17following initialization function::
18
19 $this->load->driver('class name');
20
21Where class name is the name of the driver class you want to invoke. For
22example, to load a driver named "Some Parent" you would do this::
23
24 $this->load->driver('some_parent');
25
26Methods of that class can then be invoked with::
27
28 $this->some_parent->some_method();
29
30The child classes, the drivers themselves, can then be called directly
31through the parent class, without initializing them::
32
Derek Jones9713cce2011-10-05 17:26:43 -050033 $this->some_parent->child_one->some_method();
34 $this->some_parent->child_two->another_method();
Derek Jones8ede1a22011-10-05 13:34:52 -050035
36Creating Your Own Drivers
37=========================
38
39Please read the section of the user guide that discusses how to :doc:`create
40your own drivers <creating_drivers>`.