Line | |
---|
1 | <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
|
---|
2 |
|
---|
3 | class 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 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.