blob: 8d0d84aaaf07d9b8b2436e932d16b5d21a0eb69d [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
33 $this->some_parent->child_one->some_method(); $this->some_parent->child_two->another_method();
34
35Creating Your Own Drivers
36=========================
37
38Please read the section of the user guide that discusses how to :doc:`create
39your own drivers <creating_drivers>`.