<?php
class Listing_model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function getListings()
{
$this->db->select('*');
$result = $this->db->get('franchise');
$array = $result->result_array();
return $array;
}
public function getListing($id)
{
$this->db->where('id', $id);
// $this->db->where('is_active !=', 0);
$this->db->select('*');
$result = $this->db->get('franchise');
$array = $result->result_array();
return $array;
}
public function setListing($save)
{
$this->db->insert('franchise', $save);
return $this->db->insert_id();
}
public function updateListing($post)
{
$this->db->where('id', $post['id']);
$this->db->update('franchise', $post);
return $post['id'];
}
public function deleteListing($id)
{
/*status(0) is for trash*/
// $post['is_active'] = 0;
$this->db->where('id', $id);
$this->db->delete('franchise');
return true;
}
public function getDesigners()
{
$this->db->select('*');
$result = $this->db->get('designer');
$array = $result->result_array();
return $array;
}
public function searchUser($keyword)
{
$this->db->where("name LIKE '%$keyword%'");
$this->db->select('user_id, name, country');
$result = $this->db->get('users');
$array = $result->result_array();
return $array;
}
public function getUser($for_id)
{
$this->db->select('user_id,name');
$result = $this->db->get('users');
$array = $result->result_array();
return $array;
}
public function getStudents()
{
$this->db->select('*');
//$this->db->join('courses', 'courses.course_id = student.course_id', 'INNER');
$result = $this->db->get('student');
$array = $result->result_array();
return $array;
}
public function setStudent($save)
{
$this->db->insert('student', $save);
return $this->db->insert_id();
}
public function getStudent($sid)
{
$this->db->where('sid', $sid);
$this->db->select('*');
//$this->db->join('courses' , 'courses.course_id = student.course_id' , 'INNER');
$this->db->join('program' , 'program.course_id = student.course_id' , 'INNER');
$this->db->join('franchise' , 'franchise.id = student.center' , 'INNER');
$result = $this->db->get('student');
$array = $result->result_array();
return $array;
}
public function updateStudent($post)
{
$this->db->where('sid', $post['sid']);
$this->db->update('student', $post);
return $post['sid'];
}
public function deleteStudent($sid)
{
$this->db->where('sid', $sid);
$this->db->delete('student');
return true;
}
}
|