<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Okada Design Blog &#187; Codeigniter</title>
	<atom:link href="http://www.okadadesign.no/blog/tag/codeigniter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.okadadesign.no/blog</link>
	<description>Welcome to Okada Design Web Development Blog</description>
	<lastBuildDate>Wed, 11 Jan 2012 23:21:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to use Codeigniter captcha plug-in Part 2</title>
		<link>http://www.okadadesign.no/blog/web-development/how-to-use-codeigniter-captcha-plug-in-part-2/</link>
		<comments>http://www.okadadesign.no/blog/web-development/how-to-use-codeigniter-captcha-plug-in-part-2/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 17:22:07 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[captcha]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=384</guid>
		<description><![CDATA[ <p>DOWN LOAD In the previous post I wrote a basic method how to use captcha plug-in with Codeigniter. Today I am going to write a simple but practical newsletter subsciption page using captcha. We will use CI&#8217;s form_validation class.</p> ci_captcha <p>Please read the previous post to customize it. You need to create a [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/how-to-use-codeigniter-captcha-plug-in/' rel='bookmark' title='How to use Codeigniter captcha plug-in Part 1'>How to use Codeigniter captcha plug-in Part 1</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-5-subscribers-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 5: subscribers module'>Codeigniter shopping cart v1.1 Part 5: subscribers module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fhow-to-use-codeigniter-captcha-plug-in-part-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fweb-development%2Fhow-to-use-codeigniter-captcha-plug-in-part-2%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.box.net/shared/s7r1q5fqll">DOWN LOAD</a><br />
<a href="http://www.okadadesign.no/blog/?p=276">In the previous post</a> I wrote a basic method how to use captcha plug-in with Codeigniter.<br />
Today I am going to write a simple but practical newsletter subsciption page using captcha.<br />
We will use CI&#8217;s form_validation class.</p>
<h3>ci_captcha</h3>
<p>Please read the previous post to customize it.<br />
You need to create a folder called captcha as the same level as system.<br />
<span id="more-384"></span></p>
<h3>Database</h3>
<p>We need two tables, captcha and subscribers.</p>
<pre class="brush: php; title: ; notranslate">

CREATE TABLE IF NOT EXISTS `captcha` (
  `captcha_id` bigint(13) unsigned NOT NULL AUTO_INCREMENT,
  `captcha_time` int(10) unsigned NOT NULL,
  `ip_address` varchar(16) NOT NULL DEFAULT '0',
  `word` varchar(20) NOT NULL,
  PRIMARY KEY (`captcha_id`),
  KEY `word` (`word`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;

CREATE TABLE IF NOT EXISTS `subscribers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=30 ;
</pre>
<h3>Config</h3>
<p>config/autoload.php</p>
<pre class="brush: php; title: ; notranslate">
$autoload['libraries'] = array('database', 'session');

$autoload['helper'] = array('url');
</pre>
<p>You can autoload library(form_validation) here as well.</p>
<h3>Model</h3>
<p>The code is from a Codeigniter book Professional CodeIgniter by Thomas Myer.</p>
<p>models/msubscribers.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

class MSubscribers extends Model{

	function MSubscribers(){
		parent::Model();
	}

function getSubscriber($id){
    $this-&gt;db-&gt;where('id',$id);
    $this-&gt;db-&gt;limit(1);
    $Q = $this-&gt;db-&gt;getwhere('subscribers');
    if ($Q-&gt;num_rows() &gt; 0){
      $data = $Q-&gt;row_array();
    }

    $Q-&gt;free_result();
    return $data;
 }

 function getAllSubscribers(){
     $data = array();
     $Q = $this-&gt;db-&gt;get('subscribers');
     if ($Q-&gt;num_rows() &gt; 0){
       foreach ($Q-&gt;result_array() as $row){
         $data[] = $row;
       }
    }
    $Q-&gt;free_result();
    return $data;
 }

 function createSubscriber(){
	$this-&gt;db-&gt;where('email', $_POST['email']);
	$this-&gt;db-&gt;from('subscribers');
	$ct = $this-&gt;db-&gt;count_all_results();

	if ($ct == 0){
		$data = array(
			'name' =&gt; $_POST['name'],
			'email' =&gt; $_POST['email']
		);

		$this-&gt;db-&gt;insert('subscribers', $data);
 	}
 }

 function updateSubscriber(){
	$data = array(
		'name' =&gt; $_POST['name'],
		'email' =&gt; $_POST['email']

	);

 	$this-&gt;db-&gt;where('id', $_POST['id']);
	$this-&gt;db-&gt;update('subscribers', $data);	

 }

 function removeSubscriber($id){
 	$this-&gt;db-&gt;where('id', $id);
	$this-&gt;db-&gt;delete('subscribers');

 } 

}//end class
?&gt;
</pre>
<h3>Controller</h3>
<p>controllers/welcome.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class Welcome extends Controller {
  function  __construct(){
    parent::Controller();
    $this-&gt;load-&gt;model('MSubscribers');
    $this-&gt;load-&gt;helper(array('form', 'url'));
    $this-&gt;load-&gt;library('form_validation');
    session_start();
    $this-&gt;output-&gt;enable_profiler(FALSE);
  }

  function index(){

    	$captcha_result = '';
	$data['cap_img'] = $this -&gt; _make_captcha();
	$this-&gt;load-&gt;view('subscribe', $data);
  }

  function subscribe(){
    /**
	 * form_validation
	 */
	$this-&gt;form_validation-&gt;set_rules('name', 'Name', 'required');
	$this-&gt;form_validation-&gt;set_rules('email', 'Email',  'required|valid_email');
	$this-&gt;form_validation-&gt;set_rules('captcha', 'Captcha', 'required');
	if ( $this -&gt; _check_capthca() ) {
        if ($this-&gt;form_validation-&gt;run() == FALSE)
		{
		    $this-&gt;session-&gt;set_flashdata('subscribe_msg', 'All fields are required . Please try again!');
		    redirect('welcome/index');
		}
		else
		{
		    $this-&gt;MSubscribers-&gt;createSubscriber();
		    $this-&gt;session-&gt;set_flashdata('subscribe_msg', 'Thanks for subscribing!');
		    redirect('welcome/index','refresh');
		}
      }else {
        $this-&gt;session-&gt;set_flashdata('subscribe_msg', 'Enter captcha . Please try again!');
	redirect('welcome/index');
      }
  }
  /**
   * For captcha
   *
   */
   function _make_captcha()
  {
    $this -&gt; load -&gt; plugin( 'captcha' );
    $vals = array(
      'img_path' =&gt; './captcha/', // PATH for captcha ( *Must mkdir (htdocs)/captcha )
      'img_url' =&gt; 'captcha/', // URL for captcha img
      'img_width' =&gt; 200, // width
      'img_height' =&gt; 60, // height
      // 'font_path'     =&gt; '../system/fonts/2.ttf',
      'expiration' =&gt; 7200 ,
      );
    // Create captcha
    $cap = create_captcha( $vals );
    // Write to DB
    if ( $cap ) {
      $data = array(
        'captcha_id' =&gt; '',
        'captcha_time' =&gt; $cap['time'],
        'ip_address' =&gt; $this -&gt; input -&gt; ip_address(),
        'word' =&gt; $cap['word'] ,
        );
      $query = $this -&gt; db -&gt; insert_string( 'captcha', $data );
      $this -&gt; db -&gt; query( $query );
    }else {
      return &quot;Umm captcha not work&quot; ;
    }
    return $cap['image'] ;
  }

  function _check_capthca()
  {
    // Delete old data ( 2hours)
    $expiration = time()-7200 ;
    $sql = &quot; DELETE FROM captcha WHERE captcha_time &lt; ? &quot;;
    $binds = array($expiration);
    $query = $this-&gt;db-&gt;query($sql, $binds);

    //checking input
    $sql = &quot;SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time &gt; ?&quot;;
    $binds = array($_POST['captcha'], $this-&gt;input-&gt;ip_address(), $expiration);
    $query = $this-&gt;db-&gt;query($sql, $binds);
    $row = $query-&gt;row();

  if ( $row -&gt; count &gt; 0 )
    {
      return true;
    }
    return false;

  }

  /**
   * End of captcha
   */
}//end controller class

?&gt;
</pre>
<h3>View</h3>
<p>views/subscribe.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
        &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;Using captcha with Codeigniter&lt;/title&gt;
  &lt;base href=&quot;&lt;?=base_url();?&gt;&quot;&gt;
  &lt;/head&gt;
&lt;body&gt;
&lt;div id='main'&gt;

&lt;?php
if ($this-&gt;session-&gt;flashdata('subscribe_msg')){
	echo &quot;&lt;div class='message'&gt;&quot;;
	echo $this-&gt;session-&gt;flashdata('subscribe_msg');
	echo &quot;&lt;/div&gt;&quot;;
}
?&gt;
&lt;?php echo form_open(&quot;welcome/subscribe&quot;); ?&gt;
&lt;?php echo form_fieldset('Subscribe To Our Newsletter'); ?&gt;
&lt;h5&gt;Name&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&lt;?php echo set_value('name'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;Email&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;Are you human?&lt;/h5&gt;
&lt;?php echo &quot;&lt;p&gt;$cap_img&lt;/p&gt;&quot; ;?&gt;

&lt;input type=&quot;text&quot; name=&quot;captcha&quot; value=&quot;&quot; size=&quot;40&quot; /&gt;

&lt;div&gt;&lt;input type=&quot;submit&quot; value=&quot;Subscribe&quot; /&gt;&lt;/div&gt;
&lt;?php echo form_fieldset_close(); ?&gt;
&lt;?php echo form_close(); ?&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2009/11/newsletter1.jpg" alt="newsletter1" title="newsletter1" width="314" height="403" class="alignleft size-full wp-image-389" /></p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/how-to-use-codeigniter-captcha-plug-in/' rel='bookmark' title='How to use Codeigniter captcha plug-in Part 1'>How to use Codeigniter captcha plug-in Part 1</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-5-subscribers-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 5: subscribers module'>Codeigniter shopping cart v1.1 Part 5: subscribers module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/web-development/how-to-use-codeigniter-captcha-plug-in-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding a third party class to CodeIgniter library</title>
		<link>http://www.okadadesign.no/blog/codeigniter/adding-a-third-party-class-to-codeigniter-library/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/adding-a-third-party-class-to-codeigniter-library/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 13:27:46 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[calendar class]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=340</guid>
		<description><![CDATA[ <p>You can find many php classes at http://www.phpclasses.org/. This time I&#8217;d like to add a new class called BBQQ calendar to library. I know that there is a calendar class for CodeIgniter, but this will show you how simple is to add a third party php class to CI.</p> Files <p>Download a zip [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/automatically-loaded-classlibrary-list-of-codeigniter/' rel='bookmark' title='Automatically Loaded Class/Library List of Codeigniter'>Automatically Loaded Class/Library List of Codeigniter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fadding-a-third-party-class-to-codeigniter-library%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fadding-a-third-party-class-to-codeigniter-library%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>You can find many php classes at <a href="http://www.phpclasses.org/">http://www.phpclasses.org/</a>.<br />
This time I&#8217;d like to add a new class called <a href="http://www.phpclasses.org/browse/package/5743.html">BBQQ calendar</a> to library. I know that there is <a href="http://codeigniter.com/user_guide/libraries/calendar.html">a calendar class</a> for CodeIgniter, but this will show you how simple is to add a third party php class to CI.</p>
<h3>Files</h3>
<p>Download a zip file from <a href="http://www.phpclasses.org/browse/package/5743.html#download">http://www.phpclasses.org/browse/package/5743.html#download</a>. You need to register and sign-in in order to see a download link. Unzip it somewhere in your desktop.<br />
Open calendar.php and replace &lt;?php with the following code at the top and save it as BBQQ_Calendar.php in application/libraries/ directory.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
</pre>
<p><span id="more-340"></span></p>
<h3>Controller</h3>
<p>Copy, paste the following code and save it as calendar.php in controllers directory.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
class calendar extends Controller {

    function __construct() {
        parent::__construct();
        $this-&gt;load-&gt;library('BBQQ_Calendar');
    }

    function index()
    {

        $this-&gt;load-&gt;view('calendar_view');
    }
}
</pre>
<h3>View</h3>
<p>Copy, paste the following code and save it as calendar_view.php in views directory.<br />
Please note that I added &lt;base href=&#8221;&lt;?=base_url();?>&#8221; /> in head section.<br />
This allows us to link a css (and javascript if you are using) file with &lt;link href=&#8221;css/example.css&#8221; media=&#8221;screen&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; > </p>
<pre class="brush: php; title: ; notranslate">
&lt;!DOCTYPE html&gt;&lt;html&gt;
&lt;head&gt;
&lt;title&gt;BBQQ CALENDAR&lt;/title&gt;
&lt;base href=&quot;&lt;?=base_url();?&gt;&quot; /&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; &gt;
&lt;link href=&quot;css/example.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; &gt;
&lt;body&gt;
&lt;h3&gt;A plain calendar with all default settings&lt;/h3&gt;
&lt;?php
$cal = new BBQQ_Calendar();
$cal-&gt;render(0);
?&gt;

&lt;h3&gt;A plain calenar with raw output, for geektool&lt;/h3&gt;
&lt;pre style=&quot;background:#333;width:420px;padding:12px;&quot;&gt;
&lt;?php
$cal-&gt;render(0, 1);
?&gt;
&lt;/pre&gt;

&lt;h3&gt;Customised Week Day Titles&lt;/h3&gt;
&lt;p&gt;change sun/sat to sunday/saturday&lt;/p&gt;
&lt;?php
$cal-&gt;setWeekDayTitle(array(
    'sun' =&gt; 'Sunday',
    'sat' =&gt; 'Saturday'
));
$cal-&gt;render(0);
?&gt;

&lt;h3&gt;Customised header&lt;/h3&gt;
&lt;?php
$cal-&gt;render(0, 0,
    '&lt;tr&gt;&lt;th colspan=&quot;7&quot; style=&quot;background:#69c;&quot;&gt;simple calendar&lt;/th&gt;&lt;/tr&gt;' .
    '&lt;tr&gt;&lt;th&gt;s&lt;/th&gt;&lt;th&gt;m&lt;/th&gt;&lt;th&gt;t&lt;/th&gt;&lt;th&gt;w&lt;/th&gt;&lt;th&gt;t&lt;/th&gt;&lt;th&gt;f&lt;/th&gt;&lt;th&gt;s&lt;/th&gt;&lt;/tr&gt;'
);
?&gt;

&lt;h3&gt;Hightlight Days With Customised Templates (Advanced Usage)&lt;/h3&gt;
&lt;?php
$days = array(
            // custom template for today
            $cal-&gt;getToday('j') =&gt; array(
                'template' =&gt; '&lt;b&gt;TODAY: :num&lt;/b&gt;'
            ),
            // highlight day: 5 with custom template/scripts and wrapper tag
            5 =&gt; array(
                'template' =&gt; '&lt;a href=&quot;event?id=event_:timestamp&quot;&gt;:num&lt;/a&gt;',
                'wrapper' =&gt; array(
                   'tag' =&gt; 'td',
                   'id'    =&gt; null,
                   'class' =&gt; 'cal-thu',
                   'format' =&gt; 'j F, Y',
                   'style' =&gt; 'color:red;background:yellow',
                   'onclick' =&gt; &quot;alert('Title: ' + this.title);return false;&quot;,
                   'title' =&gt; ':title'
                )
            ),
            // highlight day: 12 with custom template and wrapper tag
            12 =&gt; array(
                'template' =&gt; '&lt;a href=&quot;?id=event_:title&quot;&gt;:num&lt;/a&gt;',
                'wrapper' =&gt; array(
                   'tag' =&gt; 'td',
                   'id'    =&gt; null,
                   'class' =&gt; 'cal-thu',
                   'format' =&gt; 'j F, Y',
                   'style' =&gt; 'color:red;background:green',
                   'title' =&gt; 'some :title'
                )
            )
        );

$cal-&gt;highlightDays($days);
$cal-&gt;render(0);
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>CSS</h3>
<p>Create a css folder as the same level as sytem, application and img folder.<br />
Find a file called example.css in the unzipped folder. Move this file to css folder.</p>
<h3>Results</h3>
<p><a href="http://www.okadadesign.no/blog/img/BBQQ-CALENDAR.jpg"><img src="http://www.okadadesign.no/blog/wp-content/uploads/2009/10/BBQQ-CALENDAR-151x300.jpg" alt="BBQQ-CALENDAR" title="BBQQ-CALENDAR" width="151" height="300" class="alignleft size-medium wp-image-352" /></a></p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/automatically-loaded-classlibrary-list-of-codeigniter/' rel='bookmark' title='Automatically Loaded Class/Library List of Codeigniter'>Automatically Loaded Class/Library List of Codeigniter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/adding-a-third-party-class-to-codeigniter-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Naming conventions for Codeigniter</title>
		<link>http://www.okadadesign.no/blog/codeigniter/naming-convention-for-codeigniter/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/naming-convention-for-codeigniter/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 19:26:17 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=160</guid>
		<description><![CDATA[ <p></p> <p>Class names must have the first letter capitalized with the rest of the name lowercase in cotoller and model.</p> class Blog extends Controller { function index() { echo &#8216;Hello World!&#8217;;} } class Model_name extends Model { function Model_name() { parent::Model(); } } <p>However you don&#8217;t need to have a capital letter for [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fnaming-convention-for-codeigniter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fnaming-convention-for-codeigniter%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://codeigniter.com/images/design/ci_logo2.gif" alt="codeigniter logo" class="alignleft" /></p>
<div class="clearer"></div>
<p>Class names must have the first letter capitalized with the rest of the name lowercase in cotoller and model.</p>
<div class="codesnip-container" >class Blog extends Controller {<br />
	function index()<br />
	{ echo &#8216;Hello World!&#8217;;}<br />
}</div>
<div class="codesnip-container" >class Model_name extends Model {<br />
    function Model_name() {<br />
        parent::Model();<br />
    }<br />
}</div>
<p>However you don&#8217;t need to have a capital letter for the file names. The file name will be a lower case version of your class name in model.<br />
application/controllers/blog.php<br />
application/model/model_name.php<br />
application/view/blog_view.php</p>
<p>This is the same for controller as well.</p>
<p><a href="http://codeigniter.com/user_guide/general/creating_libraries.html">Naming for Libraries</a></p>
<p>File names must be capitalized. For example:  Myclass.php<br />
Class declarations must be capitalized. For example:  class Myclass<br />
Class names and file names must match.</p>
<p>You can find more details <a href="http://codeigniter.com/user_guide/general/styleguide.html#class_and_method_naming">here</a>.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/naming-convention-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

