Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function valas_get_data($filter = array(), $limit = 10, $start = 0, $count = FALSE, $debug = FALSE) {
- $head_table = 'main';
- $this->db_main->reset_query();
- $this->db_main->from($this->tables_realname[$head_table]." i");
- //category
- $this->db_main->join($this->tables_realname['category']." c","i.item_cat=c.cat_code","left");
- $this->db_main->like("i.item_cat","cur");
- if (isset($filter['get_all'])) {
- $this->db_main->where($filter['get_all'][0], $filter['get_all'][1]);
- }
- if (isset($filter['where_field'])) {
- $this->db_main->where($filter['where_field']);
- }
- if (isset($filter['where_like_field'])) {
- $this->db_main->like($filter['where_like_field']);
- }
- if (!isset($filter['show_all'])) {
- $this->db_main->where('i.deleted', 0);
- }
- //if (!isset($filter['show_all'])) {
- //============DATATABLE
- if (isset($filter['datatable_search'])){
- $this->db_main
- ->group_start()
- ->or_like('item_code',$filter['datatable_search'])
- ->or_like('item_title',$filter['datatable_search'])
- ->group_end();
- }
- //==============COUNT=============
- if ($count) {
- $this->db_main->select("count({$this->tables_id[$head_table]}) c");
- $data = $this->db_fetch(TRUE);
- return $data['c'];
- }
- //==================SHOW==========
- if (isset($filter['show_fields'])) {
- $this->db_main->select($filter['show_fields']);
- }
- //================order by=== kondisikan
- if (!isset($filter['order_by'])) {
- $this->db_main->order_by('kode', 'asc');
- } else {
- $this->db_main->order_by($filter['order_by'][0], $filter['order_by'][1]);
- }
- $this->db_main->limit($limit, $start);
- $data = $this->db_fetch();
- if ($debug) {
- $sql = $this->db_main->last_query();
- return array('data' => $data, 'sql' => $sql, 'filter' => $filter);
- } else {
- return $data;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement