Active Record – update

The U of CRUD represents the process to update data record(s) from a database in a database. CodeIgniter uses the database function $this->db->update() to update database records; this recipe will explain how it is done.

Getting ready

The following is the SQL code required to support this recipe; you'll need to adapt it to your circumstances.

CREATE TABLE IF NOT EXISTS `ch6_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(50) NOT NULL, `lastname` varchar(50) NOT NULL, `username` varchar(20) NOT NULL, `password` varchar(20) NOT NULL, `created_date` int(11) NOT NULL, `is_active` varchar(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO `ch6_users` (`firstname`, ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.