course controller added
This commit is contained in:
parent
c661a70a4a
commit
35a321c028
111
Apollo/api/application/models/Course_model.php
Normal file
111
Apollo/api/application/models/Course_model.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: karthi
|
||||
* Date: 11/23/17
|
||||
* Time: 4:58 PM
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Course_model extends CI_Model {
|
||||
|
||||
|
||||
/*
|
||||
* add course details
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function addCourse($arrayDetails=null)
|
||||
{
|
||||
|
||||
$this->db->select('CourseID');
|
||||
$this->db->where('CourseID', $arrayDetails['CourseID']);
|
||||
if($this->db->get(COURSE)->first_row()){
|
||||
$result['courseStatus'] = false;
|
||||
$result['message'] = "This course id is already exist!";
|
||||
} else {
|
||||
$this->db->insert(COURSE, $arrayDetails);
|
||||
if ($this->db->affected_rows() == '1') {
|
||||
|
||||
$result['courseStatus'] = true;
|
||||
$result['message'] = "Successfully course details added";
|
||||
} else {
|
||||
$result['courseStatus'] = false;
|
||||
$result['message'] = "Something went wrong.please try again";
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get branch details
|
||||
* parama id
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function getCourse()
|
||||
{
|
||||
$this->db->select('CU.CourseID,CU.CourseName,CU.IsActive,US.UniversityID,US.UniversityName');
|
||||
$this->db->from(COURSE.' as CU');
|
||||
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
|
||||
$this->db->order_by('CourseID','DESC');
|
||||
$courseDetails = $this->db->get();
|
||||
|
||||
if($courseDetails->result()){
|
||||
|
||||
$result['courseStatus'] = true;
|
||||
$result['details'] = $courseDetails->result();
|
||||
}
|
||||
else {
|
||||
$result['courseStatus'] = false;
|
||||
$result['message'] = "No records found!";
|
||||
}
|
||||
|
||||
$result['universityDetails'] = $this->getUniversityDetails();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* update course details
|
||||
* created by kms
|
||||
* */
|
||||
public function updateCourse($arrayDetails=null)
|
||||
{
|
||||
$this->db->where('CourseID',$arrayDetails['CourseID']);
|
||||
$upateStatus=$this->db->update(COURSE, $arrayDetails);
|
||||
if($upateStatus){
|
||||
|
||||
$result['courseStatus'] = true;
|
||||
$result['message'] = "Successfully course details updated";
|
||||
}
|
||||
|
||||
else {
|
||||
$result['courseStatus'] = false;
|
||||
$result['message'] = "Something went wrong.please try again";
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
/*
|
||||
* get university details
|
||||
* created by kms
|
||||
* */
|
||||
public function getUniversityDetails()
|
||||
{
|
||||
$this->db->select('UniversityID,UniversityName');
|
||||
$this->db->order_by('UniversityID','ASC');
|
||||
$this->db->order_by('IsActive','1');
|
||||
$universityDetails = $this->db->get(UNIVERSITY);
|
||||
return $universityDetails->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user