Created
July 9, 2015 08:37
-
-
Save dmacompton/d22adcc3075dda0a38c6 to your computer and use it in GitHub Desktop.
CI model public
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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