Skip to content

Instantly share code, notes, and snippets.

@dmacompton
Created July 9, 2015 08:37
Show Gist options
  • Save dmacompton/d22adcc3075dda0a38c6 to your computer and use it in GitHub Desktop.
Save dmacompton/d22adcc3075dda0a38c6 to your computer and use it in GitHub Desktop.
CI model public
<?php
class Model_general extends CI_Model {
function getData($table, $where=FALSE, $sort_by=FALSE, $limit=FALSE, $select=FALSE){
if($select){
$this->db->select($select);
}
if($where){
$this->db->where($where);
}
if($sort_by){
$this->db->order_by($sort_by[0], $sort_by[1]);
}
if($limit){
$this->db->limit($limit);
}
return $this->db->get($table);
}
function getList($table, $field='name', $where=false, $distinct=true){
$this->db->select($field);
if($distinct)
$this->db->distinct();
if($where)
$this->db->where($where);
$list=$this->db->get($table)->result_array();
foreach($list as $value){
$new_list[]=$value[$field];
}
return $new_list;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment