1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
6 <title>Using CodeIgniter Drivers : CodeIgniter User Guide
</title>
8 <style type='text/css' media='all'
>@import url('../userguide.css');
</style>
9 <link rel='stylesheet' type='text/css' media='all' href='../userguide.css'
/>
11 <script type=
"text/javascript" src=
"../nav/nav.js"></script>
12 <script type=
"text/javascript" src=
"../nav/prototype.lite.js"></script>
13 <script type=
"text/javascript" src=
"../nav/moo.fx.js"></script>
14 <script type=
"text/javascript" src=
"../nav/user_guide_menu.js"></script>
16 <meta http-equiv='expires' content='-
1'
/>
17 <meta http-equiv= 'pragma' content='no-cache'
/>
18 <meta name='robots' content='all'
/>
19 <meta name='author' content='ExpressionEngine Dev Team'
/>
20 <meta name='description' content='CodeIgniter User Guide'
/>
25 <!-- START NAVIGATION -->
26 <div id=
"nav"><div id=
"nav_inner"><script type=
"text/javascript">create_menu('../');
</script></div></div>
27 <div id=
"nav2"><a name=
"top"></a><a href=
"javascript:void(0);" onclick=
"myHeight.toggle();"><img src=
"../images/nav_toggle_darker.jpg" width=
"154" height=
"43" border=
"0" title=
"Toggle Table of Contents" alt=
"Toggle Table of Contents" /></a></div>
29 <table cellpadding=
"0" cellspacing=
"0" border=
"0" style=
"width:100%">
31 <td><h1>CodeIgniter User Guide Version
2.1.3</h1></td>
32 <td id=
"breadcrumb_right"><a href=
"../toc.html">Table of Contents Page
</a></td>
36 <!-- END NAVIGATION -->
39 <!-- START BREADCRUMB -->
40 <table cellpadding=
"0" cellspacing=
"0" border=
"0" style=
"width:100%">
43 <a href=
"http://codeigniter.com/">CodeIgniter Home
</a> ›
44 <a href=
"../index.html">User Guide Home
</a> ›
45 Using CodeIgniter Drivers
47 <td id=
"searchbox"><form method=
"get" action=
"http://www.google.com/search"><input type=
"hidden" name=
"as_sitesearch" id=
"as_sitesearch" value=
"codeigniter.com/user_guide/" />Search User Guide
<input type=
"text" class=
"input" style=
"width:200px;" name=
"q" id=
"q" size=
"31" maxlength=
"255" value=
"" /> <input type=
"submit" class=
"submit" name=
"sa" value=
"Go" /></form></td>
50 <!-- END BREADCRUMB -->
55 <!-- START CONTENT -->
58 <h1>Using CodeIgniter Drivers
</h1>
61 <p>Drivers are a special type of Library that has a parent class and any number of potential child classes. Child classes have access to the parent class, but not their siblings. Drivers provide an elegant syntax in your
<a href=
"controllers.html">controllers
</a> for libraries that benefit from or require being broken down into discrete classes.
</p>
63 <p>Drivers are found in the
<dfn>system/libraries
</dfn> folder, in their own folder which is identically named to the parent library class. Also inside that folder is a subfolder named
<kbd>drivers
</kbd>, which contains all of the possible child class files.
</p>
65 <p>To use a driver you will initialize it within a controller using the following initialization function:
</p>
67 <code>$this-
>load-
>driver('
<var>class name
</var>');
</code>
69 <p>Where
<var>class name
</var> is the name of the driver class you want to invoke. For example, to load a driver named "Some Parent" you would do this:
</p>
71 <code>$this-
>load-
>driver('
<var>some_parent
</var>');
</code>
73 <p>Methods of that class can then be invoked with:
</p>
75 <code>$this-
>some_parent-
>some_method();
</code>
77 <p>The child classes, the drivers themselves, can then be called directly through the parent class, without initializing them:
</p>
79 <code>$this-
>some_parent-
>child_one-
>some_method();
<br />
80 $this-
>some_parent-
>child_two-
>another_method();
</code>
82 <h2>Creating Your Own Drivers
</h2>
84 <p>Please read the section of the user guide that discusses how to
<a href=
"creating_drivers.html">create your own drivers
</a>.
</p>
94 Previous Topic:
<a href=
"creating_libraries.html">Creating Libraries
</a>
95 ·
96 <a href=
"#top">Top of Page
</a> ·
97 <a href=
"../index.html">User Guide Home
</a> ·
98 Next Topic:
<a href=
"creating_drivers.html">Creating Drivers
</a>
100 <p><a href=
"http://codeigniter.com">CodeIgniter
</a> · Copyright
© 2006 -
2012 · <a href=
"http://ellislab.com/">EllisLab, Inc.
</a></p>