%PDF- %PDF-
Direktori : /home/ugotscom/public_html/sterren/application/modules/api/models/ |
Current File : /home/ugotscom/public_html/sterren/application/modules/api/models/Common_model.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class common_model extends CI_Model { public function __construct() { parent::__construct(); $this->load->database(); } function edit($table, $condition = array(), $data_array = array()) { if ($condition) { $this->db->where($condition); } if ($this->db->update($table, $data_array)) { return true; } else { return false; } } function get_all_data($table, $limit , $condition = array(), $order_by_fieled = '', $order_by_type = "asc") { $this->db->from($table); if ($condition) { $this->db->where($condition); } if ($order_by_fieled) { $this->db->order_by($order_by_fieled, $order_by_type); } $this->db->limit($limit); $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result_array(); } else { return array(); } } function get_all_entries($table, $row = 0, $limit = 100, $condition = array(), $order_by_fieled = '', $order_by_type = "asc") { //$this->db->where('blog_status','E'); if ($condition) { $this->db->where($condition); } if ($order_by_fieled) { $this->db->order_by($order_by_fieled, $order_by_type); } $query = $this->db->get($table, $limit, $row); if ($query->num_rows() > 0) { return $query->result_array(); } else { return array(); } } function get_all($table, $condition = array(),$field='', $order_by_fieled = '', $order_by_type = "asc") { if($field){ $this->db->select($field); } $this->db->from($table); if ($condition) { $this->db->where($condition); } if ($order_by_fieled) { $this->db->order_by($order_by_fieled, $order_by_type); } $query = $this->db->get(); if ($query->num_rows() > 0) { return $query->result_array(); } else { return array(); } } function countrows($table, $condition = array()) { $this->db->from($table); if ($condition) { $this->db->where($condition); } $query = $this->db->get(); $row = $query->num_rows(); return $row; } function add($table, $data_array = array()) { $this->db->insert($table, $data_array); return $this->db->insert_id(); } function delete($table, $condition = array()) { $this->db->where($condition); $this->db->delete($table); } function get_field_data($table, $condition = array(), $field = '') { $this->db->select($field); $this->db->from($table); $this->db->where($condition); $query = $this->db->get(); if ($query->num_rows() > 0) { $firstname = $query->row(); $return_value = $firstname->$field; return $return_value; } } } ?>