1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
class Parts_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
public function add_Parts($PartsData){
$qry = $this->db->insert('parts',$PartsData);
if ($this->db->trans_status() === TRUE)
{
$this->db->trans_commit();
return TRUE;
}else
{
$this->db->trans_rollback();
return false;
}
}
public function getPartsData($Parts_id='',$view=''){
$cond = (!empty($view))?" status IN ($view) ":" status != '2' ";
$cond .= (!empty($Parts_id))?" AND id='$Parts_id' ":"";
$PartsData = $this->db->query("SELECT * FROM parts WHERE $cond Order by id DESC");
if(!empty($PartsData)){
return (empty($Parts_id))?$PartsData->result():$PartsData->row();
}
return 0;
}
public function update_Parts($id,$PartsData)
{
$this->db->where('id',$id);
$qry = $this->db->update('parts',$PartsData);
return true;
}
function changeStatus($Parts_id = '', $status = '0'){
if(empty($Parts_id)){
return 0;
}
$status = $this->db->update('parts',array('status'=>$status),array('id'=>$Parts_id));
return $status;
}
}