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

class FaqModel extends CI_Model { 

    public function __construct(){
		parent::__construct();
		$this->load->database();
	}
	
	function get_rows($where)
    {
		$sql = "select * from faqs_tb where id > 0 and isDeleted = 0 ".$where;
		$query = $this->db->query($sql);
		return $query->result_array();
	}

	public function insert_row($insert_data)
	{
		$this->db->insert('faqs_tb', $insert_data);
	}

	function delete_row($edit_id)
    {		
		$this->db->delete('faqs_tb', array('id' => $edit_id));
	}
	
	function get_row($id)
    {
		$sql = "select * from faqs_tb where id = '".$id."'";
		$query = $this->db->query($sql);
		return $query->row_array();
	}

	public function update_row($update_data, $id)
	{
		$this->db->update('faqs_tb', $update_data, $id);
	}	

	function get_admin_rows($where)
    {
		$sql = "select faqs_tb.*, site_tb.title as site 
				from faqs_tb
				left join site_tb on faqs_tb.site_id = site_tb.id
				where faqs_tb.id > 0 and faqs_tb.isDeleted = 0 ".$where;
		$query = $this->db->query($sql);
		return $query->result_array();
	}
}