source: pro-violet-viettel/sourcecode/application/core/MY_Model.php @ 364

Last change on this file since 364 was 337, checked in by namnd, 11 years ago
File size: 918 bytes
Line 
1<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
2
3class MY_model extends CI_Model
4{
5        protected $table_name = '';
6        protected $id_name = '';
7       
8        function __construct()
9        {
10                parent::__construct();
11        }
12       
13        function insert($data)
14        {
15                return $this->db->insert($this->table_name, $data);
16        }
17       
18        function update($id, $data)
19        {
20                $this->db->where($this->id_name, $id);
21                return $this->db->update($this->table_name, $data);
22        }
23       
24        function delete($id)
25        {
26                return $this->db->delete($this->table_name, array($this->id_name => $id));
27        }
28       
29        function search_by_id($id)
30        {
31                $this->db->select('*')->from($this->table_name)->where($this->id_name, $id);
32                $query = $this->get();
33                if($query->num_rows() > 0)
34                {
35                        $row = $query->row_array();
36                        return $rows;
37                }
38        }
39       
40        function get_list()
41        {
42                $query = $this->db->get($this->table_name);
43                return $query->result();
44        }
45}
Note: See TracBrowser for help on using the repository browser.