• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Efficient way of handling Tasks and ToDos

In my web application I have two separate controllers. One is a Task controller and the other is a ToDo controller. Both are virtually the same thing except they get their data from different tables and the only difference between the tables is that one column is different.

What is the most efficient way of handling this without having to create multiple controllers and models that almost do the same exact thing?


I would create a single private function that does all the work, that include a single flag of which item you are using. Then two public functions, that only call the private one with the appropriate flag.
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class App extends CI_Controller {

    public function __construct()
    public function index()
        // Something
    public function todo()
    public function tasks()
    private function _load($task)
        // All your code goes here.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.