<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Schoolmodel extends CI_Model {




function addnewcampuscourse($data)
{// Query to insert data in database
  
     $courseid = $data['courseid'];
  $departmentid = $data['departmentid'];
  $campusid = $data['campusid'];
    $programeid = $data['programeid'];

   $this->db->where('courseid',$courseid);
    $this->db->where('departmentid',$departmentid);
     $this->db->where('campusid',$campusid);
    
  
   $q = $this->db->get('coursedepartment');
    $this->db->trans_start();
   if ( $q->num_rows() <0) 
   {
      


      $this->db->insert('coursedepartment', $data);
       if ($this->db->affected_rows() > 0) 
      {
  return true;

      }


 

  

   }else {

     return false;

   }
}
   

    function getschoolbyid($id){

if($id!=null){
$this->db->select(" * from  school where id= '$id'");

$bioquery = $this -> db -> get();
if($bioquery->num_rows()>0){

   return $bioquery->result_array();
   


}else{

  return false;
}

}


}

function addnewschool($data)
{
// Query to insert data in database
  //$regnumber = $data['regnumber'];
  
    $this->db->insert('school', $data);
  if ($this->db->affected_rows() > 0) 
      {
  return true;

      }


   else

   {

     return false;

   }


}
           
 

 function populateschool()
 

{


   $query1 = $this->db->get('school');
       
 if($query1 -> num_rows() >0)

   {
  return $query1->result();

   }

   else

   {

     return false;

   }

}
   public function getcoursecampus($cam_id)
    {
            $this->db->select('*');
        $this->db->from('coursedepartment');
        $this->db->where('campusid',$cam_id); 
        $query = $this->db->get();
    return $query->result();
    }     
  



       public function getcoursebyid($cam_id)
    {
            $this->db->select('*');
        $this->db->from('course');
        $this->db->where('id',$cam_id); 
        $query = $this->db->get();
    return $query->result();
    } 





}






 ?>

