[CodeIgniter]カラム名一覧取得
カラム名一覧取得
application/core/MY_Model.phpとかに追記
public function get_column_names($table = '', $format = '%s') { $names = $this->db->list_fields(empty($table) ? $this->name : $table); if(!empty($format)){ foreach($names as &$name){ $name = sprintf($format,$name); } } return $names; }