Code Igniter - MVC Tips
The thing about any MVC (Model-View-Controller) framework is that it seperates your program logic from your HTML from your database access. You can however query your database in the model and format the result to be returned so that it is already in HTML, all ready for display. So all you need to do is to assign your model result to a $data['result'] array item ready for display and echo it in your view file. Nothing wrong with that and its a matter of taste and preference.
However… The purpose of MVC frameworks is that it seperates your program logic from your HTML from your database access!! A GOOD rule of thumb is to always keep all HTML in your view files, logic in your controllers and database access in your model files.
Derek Allard did a BRILLIANT vodcast tutorial. It even shows you how to utilize the script.aculo.us AJAX library to do AJAX calls in your application! The ONLY thing that I found wrong was that he mix HTML in his models (to be fair, it was due to an AJAX call and for the sake of time I do understand!). As I’ve said, there is nothing wrong with it technically, but if you keep things where they are supposed to be (HTML in your view files) then you know exactly where to go look for issues without even thinking about it. It will also make co.labs easier since I will not wonder where what is generated that was written by some other developer, etc…
BTW, Derek, I’m a big fan.

![]()
technorati tags:codeigniter, mvcframeworks, php, scriptaculous
Blogged with Flock
4 Comments to "Code Igniter - MVC Tips"
Spit it out!
Code Igniter Stii
Recent Posts
- Lifestreaming and Twitter is making us lazy
- Days with my father
- Friday morning fail by a stripper
- Got Springleap!
- Afrigator vs Regator
- Don’t pirate music/movies! You might be forced to use Windows if you do…
- Pike > Python?
- Using Twhirl for FriendFeed
- Being anti-social SUCKS!
- Example using XFN and Optimus to find friends on Afrigator
My Posse
- Jayx’s bloggy
- Gogo’s blog
- Go2 South Africa
- Stumble Upon
- Dave Duarte
- Wikipedia
- zlythern
- Max Kaizen
- Tresblue
- Mike Stopforth
- RafiQ
- Muti.co.za
- Employmint
- Danette’s Bloggy!
- Thinking Machine
- White African
- kiefpiet.co.za
- Skuff’s World
- Goozeberry
- Crossloop blog
- Crossloop
- Aquila Online
- Charl van Niekerk
- Derek Allard
- Code Igniter
- Carls
- Justin Hartman
- blik.co.za
- Stefano Sessa
- Uno de Waal
- Amplitude!
- bLaugh
- Tyler Reed
- Chris Rawlinson
- Stormhoek!
- 3am
- Mike Solomon
- Mobile Q and A
- Eric Edelstein
- Marc Forrest
- Imel Rautenbach
- Absolutewillie
- Vincent Maher
- Colin Daniels
- Groogle!
- Chilibean
- Paul Jacobson
- Ayelet
- Python Guru Neil
- Rails Guru Nic
- Beverley Merriman
- Miguel
- Nic Harrywhatshisname
- Chris iMod
- Geekrebel!
- Steven McD
- Belinda sweetheart!
- Henre Rossouw
- JPGeek
- Foxinni
- Adii
- Charl Norman
- Bandwidthblog
- Jason Bagley
- Simon Botes
- Auric Silverwing
- Mark Forrester
- Saul Kropman
- Fred Roed
- Sass Schultz
- Gregor Rohrig
- Catherine Lückhoff
- Toastmasters
Filed in
- Afrigator (26)
- ajax (9)
- API (2)
- Apple stuff (10)
- Blogging (25)
- browsers (5)
- Business (28)
- Code Igniter (8)
- firefox (8)
- flock (14)
- Funnies (73)
- GeekDinner! (18)
- General and sometimes Rants (48)
- Go2SA (2)
- ideas 2.0 (14)
- javascript (12)
- Kick-ass Tools (30)
- Linux (5)
- Marketing (25)
- moo.ajax (4)
- mootools (6)
- Open Source (10)
- Programming (33)
- C# (1)
- PHP (13)
- Python (9)
- Ruby (on Rails) (9)
- RSS (5)
- Semantic Web (32)
- Social Web (57)
- Software Development (15)
- South Africa (33)
- Tagging (6)
- Techie stuff (22)
- Tshirts (3)
- Tutorials (42)
- Blogging (17)
- Flocking (6)
- muti.co.za (13)
- Web 2.0 (73)
- web development (20)
Past Stuff
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006















Wow, what a timely day to discover your site.
Boy do I regret taking that shortcut. Truthfully I had recorded that part a bunch of times and it just seemed so long and overly complicated to describe doing it properly, so I just decided to output a list directly for the sake simplicity (and my own sanity). If I had to do it over again, I’d use a view
Since this is my first comment here, let me just say I like your style, and you’ve got one more interested reader in me!
I can just say that anything that lets my man Stii work faster has got my vote. I mean he was a machine before using code igniter, but man now…. HE COOKS
I agree with this article. When Derek was used this solution (unfortunately in tutorial!), he must notice this.
[...] Code Igniter - MVC Tips , by Stii Pretorius Check his articles about Codeigniter [...]