Implement Functionality of Yii 1.x in Codeigniter

Hello Friends,

I am currently working in Codeigniter. Before that i have worked on Yii 1.1.14.

I loved to woked in Yii. So Again I want to connect with Yii and Want to manage codeigniter the same way as Yii manage. Like,

In Model

  1. Attributes labels

  2. Validation Rules

  3. Relation

  4. Search Method in model

  5. Behaviours

  6. Set Scenarios for validation rules (for update or create)

In Controller all CRUD methods , access control, filters, load model

How to Handle Views, Ajax Validation, Modle listing with ajax and search?

Any Tips & Tricks,ideas , Suggestion will be appreciated.

My Controller


class rejected_keyword extends MY_Controller {

    

    public $base_url ;

    

    public function __construct() {

        

        parent::__construct();

        

        $this->base_url = base_url().__CLASS__;

        //."/".$this->uri->segment(2)

    }

    

    

    

    

    /*

     * Listing

     */

    public function index(){

        

        $this->load->library('my_pagination');

        

    }

    

    

    

    

    /*

     * Create

     */

    public function create(){


       $this->load->model("rejected_keyword_model","model"); 

       if(!empty($_POST)){

           

            if($this->model->save()){

            

            

                

                

            }

       }

        

       // $data["page_title"]     = "Rejected Character - ".ucwords(__FUNCTION__);

        

        $this->load->view('admin/head',$data);

        $this->load->view("admin/rejected_keyword/form");

        $this->load->view('admin/footer');

    }

    

    

    

    

    /*

     * Update

     */

    public function update(){

        

        

        

    }

    

    

    /*

     * View

     */

    public function view(){

        

        

        

    }

    

    

    

    /*

     * Delete

     */

    public function delete(){

        

        

    }

 

}

My Model


class Rejected_keyword_model extends CI_Model {


    public   $tableName     = "rejected_keyword";

    public   $primaryKey    = "rejected_keyword_id";

    public   $labels;

    

    public function __construct() {

        parent::__construct();

        

        $this->labels = $this->attributeLabels();

    }


    

    /*

     * @Author : Yatin Mistry

     * @Desc   : This is form validation rules for model.

     * @Params : 

     *      - $action : create or update so yyou can diffrentiate validate while create or update

     */

    public function rules($action=""){

        

        $this->form_validation->set_rules('keywords',       'keywords',     'trim|required');

        $this->form_validation->set_rules('module_name',    'Module Name', 'trim|required|max_length[100]');

    }

    

    

    /*

     * 

     */

    public function attributeLabels(){

        

        return array(

            "rejected_keyword_id"   => "ID",

            "module_name"           => "Module Name",

            "keywords"              => "Keywords",

            "description"           => "Description",

            "created_on"            => "Created On",

            "modified_on"           => "Modified On",

            "created_by"            => "Created By",  

            "modified_by"           => "Modified By",

            

            

        );

    }

    /*

     * Save : Add / Update supplier api data

     */

    public function save($id=""){

        

	 $this->rules();

        if ($this->form_validation->run()){

            

            $data = $this->input->post();	


            if(!empty($id)){             //Update


                   return $this->db->where($this->primaryKey,$id)->update($this->tableName, $data);   

            }else{                      //Insert


                return $this->db->insert($this->tableName, $data);


            }		

        }

    }

    

    

    

    /*

     * Fetch one record form 

     */

    public function fetch($id){

		

        if(empty($id))return false;

        $query = $this->db->get_where($this->tableName,array($this->primaryKey => $id));

        return $query->row_array(); 

    }

    

    

    

}