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

class Gallery_Category_model extends MY_Model {

  public function get_gallery_cat($limit = '10', $offset = '0', $param = array()) {
    $status = @$param['status'];
    $id = @$param['id'];
    $parent_id = @$param['parent_id'];
    $keyword = trim($this->input->get_post('keyword', TRUE));
    $keyword = $this->db->escape_str($keyword);
    if ($status != '') {
      $this->db->where("status", "$status");
    }
    if ($id != '') {
      $this->db->where("category_id", "$id");
    }
    if ($parent_id != '') {
      $this->db->where("parent_id", "$parent_id");
    }
    if ($keyword != '') {
      $this->db->like('name', "$keyword");
    }

    //$this->db->order_by('sort_order');
    //$this->db->order_by('faq_id',"DESC");
    //$this->db->limit($limit,$offset);
    $this->db->select('SQL_CALC_FOUND_ROWS*', FALSE);
    $this->db->from('wps_gallery_category');
    if($parent_id!=''){
    $this->db->where('parent_id =',$parent_id);
  }
    $q = $this->db->get();
    //echo_sql();
    $result = $q->result_array();
    $result = ($limit == '1') ? $result[0] : $result;
    return $result;
  }
}
?>