Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Logging
#2

[eluser]heavenquake[/eluser]
In MVC generally and CodeIgniter specifically you communicate with the database through models.

I would write a model and place it in the models folder.

Then I would do:
Code:
$this->load->model('logs');
$this->logs->save($log_type, $log_message);

when I need to save stuff and

Code:
$this->load->model('logs');
$logs = $this->logs->read($log_type); //this function should get all logs of the given type as an array

When I need to view stuff.

the code for the model would be like this:

Code:
class Logs extends Model {

   function save($log_type, $log_message)
   {
       //code to save in database
   }

   function read($log_type)
   {
       //code to read from database
   }

}

Have a look at the userguide pages on models ( http://ellislab.com/codeigniter/user-gui...odels.html ) and database access ( http://ellislab.com/codeigniter/user-gui...index.html ) for more info


Messages In This Thread
CodeIgniter Logging - by El Forum - 02-21-2010, 03:52 PM
CodeIgniter Logging - by El Forum - 02-21-2010, 06:44 PM
CodeIgniter Logging - by El Forum - 02-22-2010, 11:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB