HomePHP Inserting, Updating and Deleting Database Rows with Code Igniter
Inserting, Updating and Deleting Database Rows with Code Igniter
You've seen some of the things you can accomplish with the Code Igniter PHP framework in earlier parts of this series. In this seventh part of the series, you will learn, through copious examples, how to perform insertions, updates and deletions on a selected MySQL table by using Code Igniter’s database class. You'll see that these tasks are very intuitive and easy to grasp, thanks to Code Igniter's friendly learning curve.
Admittedly, using a third-party PHP framework for building web applications rapidly confronts a PHP programmer with several challenging tasks, such as installing its source files and folders in the testing web server, probably editing and configuring a bunch of initialization parameters, and dealing with its learning curve.
Although in certain cases, all of these tasks can be accomplished in a relatively painless way, the truth is that there are several PHP frameworks available nowadays on the web that are pretty difficult to set up, and certainly come packaged with many features that can be quite overwhelming, particularly for inexperienced developers.
Fortunately, this isn’t the case with Code Igniter (http://codeigniter.com), a compact and powerful PHP framework developed in PHP 4 that permits you to create full-featured web applications very quickly. Among other things, it features a friendly learning curve.
And now that I mentioned the term “friendly,” you may recall that during the preceding article of this series, I demonstrated how easy it is to perform conditional SELECT statements against a selected table with the Code Igniter’s database class. Indeed, this class not only allows you to run queries using a traditional approach; it also allows you to select, insert, update and delete database records by means of the active record pattern, which lets you avoid coding SQL clauses explicitly.
In the aforementioned article I developed a couple of hands-on examples aimed at demonstrating how to select a few database rows via the active record approach. However, as I said before, Code Igniter lets you perform inserts, updates, and deletion operations using this design pattern as well.
Therefore, in the next few lines I’ll be discussing these interesting topics, as always, by means of several code samples. So, are you ready to learn how to insert, update and delete database records with Code Igniter? Then don’t waste more time in preliminaries. Start reading now!