Skip to content

Instantly share code, notes, and snippets.

@eboominathan
Created December 30, 2017 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eboominathan/a35f4b9eb561f15e1bebdf138bdb95c8 to your computer and use it in GitHub Desktop.
Save eboominathan/a35f4b9eb561f15e1bebdf138bdb95c8 to your computer and use it in GitHub Desktop.
Common Helper
<?php
function converToTz($time="",$toTz='',$fromTz='')
{
$date = new DateTime($time, new DateTimeZone($fromTz));
$date->setTimezone(new DateTimeZone($toTz));
$time= $date->format('Y-m-d H:i:s');
return $time;
}
function get_selected_data($table_name,$where,$select,$order_by){
$ci = &get_instance();
$ci->load->database();
if(!empty($select)){
return $ci->db->select($select)->order_by($order_by,'desc')->get_where($table_name,$where)->result();
}
}
function get_data($table_name,$where){
$ci = &get_instance();
$ci->load->database();
return $ci->db->get_where($table_name,$where)->row();
}
function update_data($table_name,$where,$data) {
$ci = &get_instance();
$ci->load->database();
return $ci->db->update($table_name,$data,$where);
}
function get_data_count($table_name,$where){
$ci = &get_instance();
$ci->load->database();
return $ci->db->get_where($table_name,$where)->num_rows();
}
function insert_data($table_name,$where){
$ci = &get_instance();
$ci->load->database();
$ci->db->insert($table_name,$where);
return $ci->db->insert_id();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment