Don't understand CI

#2
[eluser]Michael Wales[/eluser]
In the past you have developed your PHP applications like this:

Code:
<?php
// index.php
$connection = @mysql_connect('localhost', 'root', '');
$db = @mysql_select_db('myapp');

$sql = 'SELECT * FROM users';
$result = @mysql_query($sql);
?>
<html>
  <head>
    <title>My Site</title>
  </head>
  <body>
    <table>
&lt;?php
  foreach ($row = mysql_fetch_assoc($result)) {
    echo '<tr><td>' . $row['username'] . '</td><td>' . $row['created_on'] . '</td></tr>';
  }
?&gt;
    </table>
  &lt;/body&gt;
&lt;/html&gt;

This is pretty much bad - your data access and manipulation, your content, design - it's all mixed into one horrible, unmaintanable, mess.

CodeIgniter is an MVC (Model-View-Controller) framework. Where we take a 3-tiered approach to development - I highly recommend Googling MVC, there are thousands of resources as it is a proven method of all sorts of software development. Basically, we seperate our application out - all of the data in one place, our HTML pages in another, and the hardcore processing stuff in a third.

Additionally, CodeIgniter offers a lot of valuable bits and pieces of code for your to use. The ActiveRecord library, for instance is very popular. Not only does it simplify the syntax when working with a database but it allows you to switch from MySQL, to MS SQL, to PostgreSQL, and beyond with little to no modification of your own code.

Things like generating random strings, working with dates and time, validating user input, handling sessions - these are all things you don't have to worry about anymore.

Check out the User Guide, screencasts, Wiki and this forum - there's a lot of information around to get you started.

Welcome to the community!


Messages In This Thread
Don't understand CI - by El Forum - 08-30-2008, 10:52 PM
Don't understand CI - by El Forum - 08-30-2008, 11:49 PM
Don't understand CI - by El Forum - 08-31-2008, 12:30 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.