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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
class MajorProblem_model extends CI_Model {
public function _consruct(){
parent::_construct();
}
function addProblems($data){
$this->db->where('problem_name',$data['problem_name']);
if($this->db->get('tbl_major_problems')->row()){
return false;
}else{
$datas = array('problem_name'=>ucfirst(strtolower($data['problem_name'])));
if($this->db->insert('tbl_major_problems',$datas)) {
return true;
}
}
}
function get_all_Problems(){
return $this->db->get('tbl_major_problems')->result();
}
function delete_problem($id){
if($this->db->delete('tbl_major_problems',array('id'=>$id))){
return true;
}
}
function get_single_problem($id){
$this->db->where('id',$id);
return $this->db->get('tbl_major_problems')->row();
}
function update_problem($data,$id){
$this->db->where('id !=',$id);
$this->db->where('problem_name',$data['problem_name']);
if($this->db->get('tbl_major_problems')->row()){
return false;
}else{
$datas = array('problem_name'=>ucfirst(strtolower($data['problem_name'])));
$this->db->where('id',$id);
if($this->db->update('tbl_major_problems',$datas)){
return true;
}
}
}
function get_all_subProblems(){
$this->db->select('tbl_major_subproblems.subproblem_name,tbl_major_subproblems.id,tbl_major_problems.problem_name');
$this->db->join('tbl_major_problems','tbl_major_problems.id = tbl_major_subproblems.problem_category_id');
return $this->db->get('tbl_major_subproblems')->result();
}
function addSubProblems($data){
$this->db->where('problem_category_id',$data['problem_category_id']);
$this->db->where('subproblem_name',$data['subproblem_name']);
if($this->db->get('tbl_major_subproblems')->row()){
return false;
}else{
$datas = array('problem_category_id'=>$data['problem_category_id'],'subproblem_name'=>ucwords($data['subproblem_name']));
if($this->db->insert('tbl_major_subproblems',$datas)){
return true;
}
}
}
function get_single_subProblem($id){
return $this->db->get_where('tbl_major_subproblems',array('id'=>$id))->row();
}
function update_subProblem($data,$id){
$this->db->where('id !=',$id);
$this->db->where('problem_category_id',$data['problem_category_id']);
$this->db->where('subproblem_name',$data['subproblem_name']);
if($this->db->get('tbl_major_subproblems')->row()){
return false;
}else{
if($this->db->update('tbl_major_subproblems',array("problem_category_id"=>$data['problem_category_id'],"subproblem_name"=>ucwords($data['subproblem_name'])),array('id'=>$id))){
return true;
}
}
}
function delete_subproblem($id){
if($this->db->delete('tbl_major_subproblems',array('id'=>$id))){
return true;
}
}
}