Sooner or later we will find the need to work with dates, maybe to create a calendar, a list of events, or even a to-do list. In our sample application, we can keep track of the errors and incidents happening in our websites. With that we could generate some nice reports about our websites.
Working with dates is usually a very repetitive task, but CI will help us and ease this task. First we are going to add a new database table, where we can keep track of the errors:
CREATE TABLE `error_logs` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `site_id` INT NOT NULL , `error` TEXT NOT NULL , `date` DATETIME NOT NULL ) ENGINE = InnoDB;
Now we can start saving our errors to the database. In order to do that we will first create a controller, application/controllers/errors.php
:
<?php class Errors extends Controller { function errors() { parent::Controller(); } function index() { $this->load->model('errors_model'); $site_id = "16...