Query binding

Binding queries is another useful security process; if you use binding with your queries, values are automatically escaped by CodeIgniter, and there is no need for you to manually do so.

Getting ready

Copy the following SQL into your database:

CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_first_name` varchar(125) NOT NULL, `user_last_name` varchar(125) NOT NULL, `user_email` varchar(255) NOT NULL, `user_created_date` int(11) NOT NULL COMMENT 'unix timestamp', `user_is_active` varchar(3) NOT NULL COMMENT 'yes or no', PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; INSERT INTO `users` (`user_first_name`, `user_last_name`, `user_email`, `user_created_date`, `user_is_active`) ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.