Created
December 30, 2017 05:52
-
-
Save eboominathan/a35f4b9eb561f15e1bebdf138bdb95c8 to your computer and use it in GitHub Desktop.
Common Helper
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 | |
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