The most requested tutorial for day five of our CodeIgniter screencast series was for an introduction to CRUD operations. We'll review how to easily create, read, update, and delete records using CI's active-records class.
Catch Up
- Day 1: Getting Started With the Framework
- Day 2: Database Selecting Methods
- Day 3: Sending Emails
- Day 4: Newsletter Signup
Day 5: CRUD Operations
- Follow us on Twitter, or subscribe to the Nettuts+ RSS Feed for more daily web development tuts and articles.
Related Posts
Check out some more great tutorials and articles that you might like
Plus Members
Source Files, Bonus Tutorials and
More for $9 a month for all TUTS+
sites in one subscription.











User Comments
( ADD YOURS )Bob August 28th
WOW
( )Andrew August 28th
Finally!! I’ve been waiting so long for this!
Thanks alot, I’m going to watch it right now
( )Alexander August 28th
Been looking forward for this one! Keep up the good work Jeffrey and thanks for this great series
( )Yoosuf August 28th
its awsome!!!, @jeff keep it up
( )RoMuLauM August 28th
Hello! Please make a itunes feed for this screencasts! I don’t have internet all time for watching… thanks for this screencasts!
( )lawrence77 August 28th
What happen to Blip Tv…
( )Jeff Way August 28th
Screencast.com is far superior.
( )Paul Davis August 29th
The audio & video aren’t synced for me. I personally prefer Blip.tv. But hey, I’m just one guy.
iPad August 29th
No Jeffrey, You can’t control volume and is more slowly.
spartcaus August 30th
i prefer Blip.tv because it can be subscribed with iTunes. i’ll appreciate if you would upload it there too.
thanx for all the screencasts!
Meshach August 31st
Personally I think the new player is a downgrade because whenever you try to move the slider it pops up and says “replay video”.
Benjamin Reid September 1st
Errr… Vimeo FTW.
Anon September 1st
blip TV always had problems for me
Aayush August 28th
I think i’ll pick CI for my current project…only designing right now…let’s see when I start developing….
hopefully it will help me build it faster….
( )Andrew August 28th
Great work Jeff. Now that I’m all caught up, found myself sitting around waiting for this.
Cheers
( )Miles Johnson August 28th
Sigh I really hate video tutorials. Just give me the code and ill figure it out myself, I hate sitting through people yabbing about it.
( )Ulrik August 28th
Source code??
( )Jeffrey Way August 28th
The source code is available to you.
( )Yoosuf August 30th
whops http://www.jeff-way.com/ is expired
james August 28th
“here, i baked you a birthday cake and it cost you absolutely nothing”
“sigh. i hate chocolate. take it back. ice cream cake next time. jeez.”
miles. nice guy!
( )Sid August 29th
“hi, my name is miles johnson. here, i put my face on my avatar just to show you guys what a lazy, ungrateful prick looks like”.
seriously, do you realize what “source code” means? it’s always right there at the top – you don’t even have to scroll down to the video if it’s not your thing.
( )Miles Johnson August 31st
I meant the code in the actual article. I don’t want to download some zip, then unzip it, then open to realize the code was crap. Theres no reason to not put the code in the article itself.
mike September 5th
Great Miles, Any reason why you are watching Jeff’s tutorials if you are such a good coder? One could be mistaken that you were not such a good coder if your watching these basic tutorials.
Jeff’s code is not crap, it is easy, readable & does what it says on the tin. Exactly how a tutorial should be, no?
Noah Hendrix August 29th
Personally I prefer screencasts because they show you a more accurate view of what working through a tutorial is like, users don’t get lost in the words when they can just watch you do it, but hey to each his own I suppose.
( )mike August 29th
Then Dont Watch? I Hate people who do things they hate.
( )Johnny Bravo September 15th
What an asshole!!
( )Miles go play with your dolls or something!!
Caleb August 28th
Great information. I would like to see more on updating records using a form with elements like drop downs and check boxes along with normal text. I know you ran out of time during this session but it has something that I think would be very useful in many projects.
As always great job.
( )netuser August 28th
I’m on a low bandwidth connection and as streaming and following the tutorials are not a practical option, used to download screencasts from blip.tv, but now no idea how to do it.
( )Jeffrey Way August 29th
Just added a download link underneath the video. Hope this helps.
( )netuser August 29th
@Jeff
Thanks a lot for the download link, you rock !!!
webn August 29th
Thanks for that link and for the nice series..
james August 28th
Jeff, this series has been extremely helpful. I’d buy you a beer if I could. Thanks buddy.
( )Eric B. August 28th
I love you, Jeff!
( )Prabhjeet August 28th
its good.
( )iFadey August 28th
Great work Jeff. I love CodeIgniter
( )Javed Gardezi August 28th
Great JW continue on … love this series
I was waiting for it for so long………..
If it’s possible please provide us the title of the next screen cast too at the end of each episode.
( )Aaron August 28th
hey thanks Jeff…. glad to see this up, been hanging out for it! Wont see the wife and kids for a few days now
( )emcgfx August 29th
Hi, can you please offer all FLV or MOV tutorial files somewhere like in video archive on your web site for download purposes. Because I could not find most of them to download. Like Diving into PHP and others. I really like all the tutorials you create, it helps me learn PHP and CodeIgniter. You explain everything very good. Thank you so much.
( )Emmanuel August 29th
Thanks for this Jeff… it will come in handy!
( )Jeff Adams August 29th
Is it wrong that I enjoy CRUD so much, its like the building blocks of all webapp life lol. To think it was so damn hard a few years ago…
( )emcgfx August 29th
I’m only starting learning CRUID, and already starting to love it
So no, its not wrong Jeff.
( )Kriesi August 29th
great as always, looking forward to the upcoming codeigniter tuts
( )emcgfx August 29th
Can you please add direct links to your videos. I like to watch them offline on my laptop. Thank you.
( )tkhobbes August 29th
Hi Jeff, absolutely great stuff, I think this is much more useful than the e-mail stuff
Anyway, what I’d love to see next time are things like
( )- get a grip on the update function (obviously – would like to see how to use it properly, by filling existing info into a form and then let the users override it)
- understand how to build more complex models – e. g. in a blog, you might have categories and you want to create categories and assign posts to a category (which you could select in a drop down or by checkboxes or similar)
- anyway, you promised that we would ultimately end up at a full blown cms-system – guess I am just waiting to get there in the long row
Dean August 29th
Am I able to download the videos from screencast.com ?
( )Just so I can watch them when I’m not online. Cheers
Guillermo Carrion August 29th
I believe you can… using something like OrbitDownloader…
( )Jeffrey Way August 29th
Just added a download link. Look underneath the video.
Rodge August 29th
i simply love this serie!
( )Shillo August 29th
This is really fun.
But for some reason it can’t find the “db” property:
Message: Undefined property: Site_model::$db
Filename: models/site_model.php
Line Number: 15
( )Jeffrey Way August 29th
Did you remember to auto load the database class – within the “autoload.php” file inside the “Config” folder?
( )adai August 29th
why not provide the url for downloading the vidioes?
( )Jeffrey Way August 29th
Just added a download link underneath the video.
( )adai August 29th
Think you ,I find the way to do what I want…
( )Guillermo Carrion August 29th
Been waiting for this one… thanks!
( )Oliver August 29th
hey
thank you very much, I watched every single video. great stuff. what I’d like to see in this series is some ajax combined with CI
would have been great for this one.
keep it up & cheers
( )Drew Barontini August 29th
I concur. I want to see some jQuery style Ajax combined wtih CI. I’ve tried to implement it in some projects, but it doesn’t appear to be all that easy.
( )Paul du Long August 29th
Thx for this video!, i was using $this -> db -> query(”UPDATE ….”); (A)
You can also grap segments trough the function in the controller.
Example:
index.php/class/test/variable/var2
class:
function test($segment,$segment2)
{
echo $segment //Will echo: variable
echo $segment2 //Will echo: var2
}
–
Offtopic, how did you get your FF so damn fast :O? Is it Mac OS that makes it so fast? Even on localhost a reload takes 2 seconds on my pc
Paul
( )David Rojas August 29th
I was watching the video and stopped it to comment here the same thing about segments
I think that’s the correct approach when Jeffrey is talking about how to deal with the id in the delete method.
Also, you can chain methods in your db model, like $this->db->where(’id’, $data)->delete(’data’);
Anyway, great video, as usual
( )Jim Martin August 29th
Thanks Jeff,
These tuts are fantastic, I really appreciate your effort in keeping these going. I am just curious, though, have you gotten this on iTunes yet? I am not seeing it.
( )Aditu August 29th
Good tutorials.
Please put some more security and encryption stuff.
BTW why did You change media player (flv changed into mp4)?
( )Aditu August 29th
Good tutorials.
Please put some more security and encryption stuff next time.
BTW why the media player changed? (flv changed to mp4, why?)
( )David Rojas August 29th
It isn’t showing on iTunes, do I have to wait for it to update or screencast.com doesn’t provide an iTunes feed?
( )ricochet August 29th
I have also been waiting on the iTunes update…
( )Jeffrey Way August 29th
The iTunes version should go up Monday.
ricochet August 31st
still waiting… it’s now Tuesday afternoon (AEST)
Muhammad Adnan August 29th
can u please Compress your videos for download ? PLUS videos as well.
( )barten August 29th
Dont know if its possible but do all this with ajax so we dont have to redirect
( )would be a nice thing to learn next:)
barten August 29th
also security stuff is something i want to learn aswell
( )Milan August 29th
Hi Jeffrey, thanks for great tutorials.
( )I am interested to see some combination of CI and AJAX.
Tutorial City August 29th
Day 5 — On update you could use the ‘get_records’ adding a link to a page where you could edit this content and then update it.
There are hundreds of ways to do it, and in some way it’s nice you didn’t do much, because we can try a couple ways
Day 6 – It would be nice to create a tutorial on how to create an admin area using sessions(cookies and/or database), and the show how to login and logout.
Great series!
( )Jim Martin August 30th
I agree with Tutorial City about the admin area. That would be a great next step.
( )arnold August 31st
I agree also
( )philpem September 3rd
Thirded. I’d love to see a little login/logout/admin area tutorial.
Maybe with a little bit of info on security (e.g. XSS without using the global XSS filter)?
Cheers,
( )Phil.
Tutorial City September 5th
Just use xss_clean(), it’s pretty straightforward.
Kevin September 6th
Also think its a good idea to show us how to make a secure login system with CI.
Nice work btw
( )emcgfx August 29th
Hi Jeff, thank you so much for filling my request. By adding direct download link to your video. This will help me a lot, since I wanted to watch your videos offline.
( )If you can please continue posting direct links to your videos. Thank you again Jeff for very good tutorials. I think you should be a programming teacher in college if you not already LOL
Jeffrey Way August 29th
No – problem. I’ll be sure to include a download link from now on.
( )Carlos August 29th
What do you search to get the videos from iTunes?
( )timo.huber August 29th
Thanks
( )Vaidotas August 30th
Maybe in Day 6 you’ll be coding Login system?
( )Aditu August 30th
It would be nice to see some session stuf (admin and users with roles) properly secured.
Also the jQuery and CodeIgniter tutorial is a nice idea. Maybe dynamic login page?
But to be honest the CRUD tutorial is not complete. What about errors? What about data validation. What about simple silent errors like storing 20 chars into 10 chars field?
( )Aditu August 30th
I checked your video in VLC media player – the audio gets broken at 5:51.
Same in Media Player Classic. U can skip that part while watching and everything stays fine but i know for sure now that the FILE IS BROKEN. Probably because you made some cut & glue operations on the file.
( )federico bana August 30th
Your videos are excellent, please keep it on.
I’d appreciate if you make one about session and cookie managing.
Thanks a lot, really
( )IgnacioRV August 30th
Thanks Jeff for another screencast!
I didn’t have any problems with the video loading, but not being able to control volume it’s a little annoying (and it went up and down a couple of times during playing)… Anyway, that’s nothing we can’t solve moving up and down the speaker’s volume =P
One question, does codeigniter have a way to manage the id of the rows. Because in the video, the id field is set to auto_increment in the database, and when you add the first element via CI, it sets it’s id to 16 when the last one was 14 (minute 16:42), which is kinda weird…
( )It’s just curiousity, but do you have any idea about what could have happened??
IgnacioRV August 30th
Ups, I missed the ? at the end of “does CI have a way to manage the id of the rows?”…
( )Tutorial City August 31st
Maybe JW set he auto-increment to be ‘2′ or he deleted a record before reording. Codeigniter is agnostic about these type of things.
( )arnold August 31st
Im also experiencing the annoying different changes of the volume in the video..
( )James August 30th
Thnx for this great videos…i’ve been following since day 1….
( )Ricardo "mAiN_iNfEcTiOn" Machado August 30th
Hi dwds.
Nice post. I’ve been working with CI for a while and I’ve started using like that – in the native way – but then I discovered the code crafter.
Basically Code Crafter is a CRUD generator, that makes your life easier by creating the Models and basic CRUD system (almost like scaffolding) by only checking your database.
Code Crafter’s Guide – http://www.datacraft.co.za//software/codecrafter_user_guide.pdf
Code Crafter’s Page – http://www.datacraft.co.za/site/products/codecrafter
( )emcgfx August 30th
Thank you, will try this as well. Did not know about this on
( )Chris Strosser August 30th
I’d like this site much better if there were text-only versions of the screencasts. I personally don’t have time to sit through a screencast and would really like to read some of the screencast series you have. It’s much easier to scan…
( )begs September 2nd
For me it’s much better to understand when watching a tut.
( )Tutorial City September 5th
I think it would be nice to have both versions. Maybe the video is not playing and you cannot follow the tutorial because there is no text version.
( )Rahul August 30th
Thanx a lot Jeff. I wanted this download option since i first saw u’r jquery tutorials. It would be great if u could provide a way to download all u’r older videos…
( )arnold August 31st
doh!..I wish there was a part 2 for day 5
CRUD operations are so good…
In Day 1,2,3,4 and upcoming screencast
…Please provide the video to be downloaded, thanks
keep the CI screencast coming!..Thanks Jeff
( )ricardino August 31st
Great tutorial, i really look forward to the next one every week. Requests for next week:
A padded out update function (making it more like an edit function)
and the basics of user authentication although is probably running before i can walk.
Once again great tutorial, really laying things out in an understandable way.
( )Shishant August 31st
Hello,
Would love to see if you record it more frequently rather than a week.
Its so awesome that waiting for a week is a pain.
( )Mateus Souza August 31st
Great post! Great screencast! Great Website!!
( )C.44 August 31st
A basic login system would be great. Some more complex queries would be great too, (joins and stuff
)
All in all this was a great tut, i’m having a little bit of trouble seeing how this code is going to end up showing a blog like you showed in the first screencast, but i love the fact that we can ask for certain topics to be discussed.
Keep it up Jeffrey
( )awake August 31st
check out Yii Framework guys
http://www.yiiframework.com/ (the framework)
http://www.yiiframework.com/yii-sites/ (sites powered by yii)
( )C.44 August 31st
A simple login routine would be great. I also love the fact that we can request subjects, although i don’t see this turning into a blog by episode X (10).
Btw, i can’t find this one on iTunes yet.
( )Cecily August 31st
I must be missing something. I’m working through this tutorial (I’m up to 16 minutes in) and when I go to look in the database to see if the “content” has been added to the database, all I see is a number 0, not the content I actually entered into the field. What am I doing wrong? Everything else seems to work.
Thanks for any help you can provide.
( )Ricardo "mAiN_iNfEcTiOn" Machado September 2nd
That must be a problem on how you are obtaining the data….
Probably you should check the lines where you get the post data. Something like:
$this->input->post(’object_name’);
ok?
( )Phil cook August 31st
@jeff firstly can I say love the series so far. I have been Reading a lot of books about oo php and the mvc pattern but didn’t know where or how to start implimenting this. So thanks.
Just a little request I like to watch these videos on my iPhone, can you provide a link in the articles to an iPhone friendly version? Many thanks.
( )Khalil August 31st
Video link is not downloading nor playing online… what to do?
( )Khalil August 31st
Finally I have download the file Thanks…
( )Marcel September 1st
Hello Jeff, I want to learn more in depth form/database handling with relational databases.
For example: 3 tables, Person, Communication, CommunicationKind.
A person can have multiple Communications(Telephone,Fax,E-mail).
When Selecting a person in a table row, It would be nice a sub-table to show up with communications which could be added or edited. With the possibility to select the communicationkind with a dropdown box.
And when the communicationkind isn’t in the dropdown box, add a new one and after adding being able to select the new item.
I am looking forward to see your new CAST
( )KEEP UP THE GOOD WORK
C.44 September 1st
Any idea when the new one (ep.6) will be available ? Waiting impatiently here haha. I’d also love to see a (simple) login/user management script.
Gotta love that we can actually ask for what we’d want to learn, gives it that much more depth. Anyway, keep it up loving these couple of series (this and the wordpress series
)
( )Shishant September 1st
http://rapidshare.com/files/273951422/CodeIgniter_From_Scratch-_Day_5.mp4_downloadOnly_true
rapidshare link, after download rename it to anything you link making sure you keep the extension as .mp4
( )Alex September 1st
Very good tutorials for CodeIgniter,great job 10000X .
I like the site too!
( )Regards,
Alex
Chris September 1st
Hey Jeff another excellent CI tutorial. Anyway you could mix some jQuery with one? Maybe show some AJAX with it?
Keep up to good work.
( )Erik September 2nd
Just a quick message to say thank you for ALL of your tutorials and especially this CI series! Got me rebuilding my portfolio with CI
topics I’m looking forward to seeing :
- internalisation (interface parts as well as contents)
- file upload (single and multiple with validation)
- login in / user management
for those interested I found an awesome and extremely simple template library that allows to easily build common sections of a website (like the header and footer parts) -> http://maestric.com/doc/php/codeigniter_template
( )Aliex Freez September 2nd
Good tutorials
How about Jquery Ajax load content to view
( )Danijel September 3rd
What I would like to see in Day 6 is how to build a tagging system where you can tag your posts/images/pages/whatever, search by tags and show related stuff.
I think it’s better than doing login system because it goes deeper in more complex SQL queries (I think, I never did one
which are much harder to learn than code a login system.
Than do login system in Day 7, and please, do it with privileges, to show us how we can restrict some users access to certain admin area parts.
Because, there are bunch of login system tutorials out there and they are very easy to apply on CI. I built normal login system, I believe, that is secure, by just using CI User Guide and little of logic
.
It’s time go much more complicated I think now when we are already in day 6.
( )Anthony F. Camilleri November 1st
I second completely – if you could show us an AJAX tagging system it would be beyond great!
( )Khalil September 3rd
Dear Jeff,
Please share next post with CI + jQuery Pagination.
Thanks,
( )Benoit September 4th
Thanks Jeff. Again, next tutorial would be nice if you digged into your Authentication library of choice, wether it be TankAuth or DX_Auth… I actually would like to know what’s your favourite auth library for CI because you opinion counts… There are many, I’m about to choose DX but I’m not sure if it’s the best?
Thanks for the great work, and thank you Envato for bringing so much energy making the world a better place for learning
( )Bryan Lewis September 4th
How much would it cost to get one on one php/codeigniter classes. Mostly just php classes. I have a good grasp on things but I want a better understanding These tuts are amazing and are helping out a great deal! Would someone at nettuts be willing to do that er no?
( )Guillermo Carrion September 4th
When is the next one coming out?
( )Chaky September 5th
Can’t wait for the next series! Thanks a lot!
( )Slatron September 5th
Took me a while, but I finally got the time to go through this tut. I’ve been using CI for a while now – but I really like seeing someone else step through the basics as a foundation refresher.
I’d like to see a lesson on URL segment Rewriting with CI.
Thanks for all the hard work, Jeffrey
( )Daniel Sitnik September 6th
Hi Jeff, thanks for the screenscats, they’re great!!
For day 6 I’d like some tips on how to create a good and flexible site structure using CI. What I mean is how can I divide things in sections (views probably) like header, content and footer and load these sections dynamically.
Thanks and keep up the good work!
( )Jason Shultz September 6th
I would have loved to see some attention giving to Update. I think that’s where a lot of us have been having issues with it. Create and Delete are fairly simple, IMO whereas Update is the tricky one to implement. Please devote some time to the next tut to Update.
( )Ryan September 7th
Great videos. I’d love to see some best practices for CI regarding ‘templates.’ That is, what’s the best way to load a common Header, Footer, etc? Should this be done in the controller or in the views? Thanks!
( )Danijel September 8th
When the next day is coming?
( )ibura September 9th
it version still ain’t up?
( )ibura September 9th
itune version
( )McGoo September 9th
Jeff when we can expect next part ???
( )Gautam September 9th
Is this podcast available for download to iTunes. I have subscribed for Nettuts podcasts in iTunes, but unable to receive this video.
Regards
( )Bryan Lewis September 9th
Jeff, I want to learn about CodeIgniter’s Template Parser Class, and how to use it with the CMS we are going to create. Is this possible?
( )kaloop September 10th
This Series is great!
For the next screencast I think it’ll be good to show us how to build a good login system with different levels of security (Like Administrator, Newser, Member, etc).
Thanks for this good screencast!
( )Martin September 18th
Question for the more experienced CodeIgniterers: would you use a templating system like Smarty in conjunction with a CI-driven site, or does CI have features that make Smarty redundant?
I am new to both and want to know if I should learn both.
( )Michael September 28th
Dying to get started with these tutorials.
Already planned out a little project.
Is there a .mov version available?
Many thanks, Jeff.
( )donie October 6th
Thanks!
( )your videos really help me a lot.
i’m going to build my new website using CI
Bart October 26th
The screencast doesn’t load. Nor can you download it. Help?
( )Eduardo October 26th
Video doesn´t work
( )Steven October 26th
Hi Jeff, Thanks for the video tutorial and it have help me a lot in learning CodeIgniter. I try to download the video for lesson 5 but couldn’t find the link. Can you please put up the video??
( )Thanks…
Steven October 26th
Hey Jeff, thanks for the wonderful tutorial on CodeIgniter. I really learn so much from your video. I am trying to download the Day 5 tutorial but the links is broken. Is it possible for you to upload it??
( )Thanks a lot…
Balazs Csaba October 28th
Hey all…
the video doens’t seem to work, nor the download link…
Please, could anybody provide a link to the video…please
Thx very much
( )Blunk October 28th
The video its gone??? 404 Not Found :S
( )Karl Ballard October 29th
Hey Jeff,
I have loved the series so far, however there isn’t a copy of this to download or on iTunes avalible. This flash player doesn’t seem to co-operate.
Many Thanks
( )Karl Ballard
Mario Hernandez October 29th
Nop, can’t watch the video either, same thing with day 6
( )John Ressing October 29th
Is this video ever going to be fixed? The download doesn’t work, and the video won’t play on the site.
( )Circoloco November 13th
I know I’m a bit behind the times but only recently stumbled upon this. Am I blind as I cant see the down load button? Been through itunes and this and day 6 are both missing? My system is that poor and old then all I get really is audio though streaming.
( )Jeffrey Way August 29th
Strange. Just watched the video last night, and everything appeared to be synced.
( )Aditu August 29th
What do you use to watch your videos?
I watch your videos using Media Player Classic on Windows – i found nothing wrong with last file although the file format changed.
( )emcgfx August 30th
Hey Jeff, I’ve finished all the videos you have posted on CodeInginter. CRUD was the last one today. Thank you so much for creating this videos, it helps me to learn a lot from you. You explain all the code in detail. A bit fast at times, I need to pause a lot to catch up. But I understood everything.
The next video would be nice about “Pagination” where you grab contents from database and show only limited amount of contents per page. Also, in the following videos, it would be nice if you could teach us how to properly make admin control panel or at least login/logout/register with sessions etc… Thank you.
( )Aditu August 30th
The file is broken. Read my other post about media players.
( )emcgfx August 30th
I personally use only VLC in both linux and windows. When watching offline screencasts.
( )