?
Current Path : /home1/savoy/public_html/savoyglobal.net/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/application/models/mastermodel.php |
<?php class Mastermodel extends CI_Model { function __construct() { parent::__construct(); } function htmlmail($subject, $content) { $this->mail->send($content, $subject, 'info@savoyglobal.net', 'Savoy Badminton Tournament 2013', 'savoy1975', 'smtp.gmail.com', 1); } function gettabledata($table, $sortfield = "", $sort_order = "asc", $primary_field = '') { $data = array(); if (!empty($sortfield)) { $this->db->order_by($sortfield, $sort_order); } if (!empty($primary_field)) { $this->db->join('master', "master.master_id=$table.$primary_field"); } $Q = $this->db->get($table); // echo $this->db->last_query(); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function getdatas($table, $sortfield = "", $sorttype = "asc", $pagenum = "") { $data = array(); $count = $this->db->count_all_results($table); $arr = $this->fpaginate->paginate($pagenum, $count); $data['startpage'] = $arr[0]; $data['endpage'] = $arr[1]; $start = $arr[2]; $perpage = $arr[3]; $data['count'] = $count; if (!empty($pagenum)) $this->db->limit($perpage, $start); if (!empty($sortfield)) { $this->db->order_by($sortfield, $sorttype); } $data['results'] = $this->db->get($table); return $data; } function getdatas1($table, $sortfield = "", $sort_order = "asc", $primary_field = '') { $data = array(); if (!empty($sortfield)) { $this->db->order_by($sortfield, $sort_order); } if (!empty($primary_field)) { $this->db->join('master', "master.master_id=$table.$primary_field"); } $Q = $this->db->get($table); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_data($table, $id, $field, $sortfield = "", $sorttype = "asc", $pagenum = "") { $data = array(); $this->db->where($field, $id); $this->db->get($table); $count = $this->db->count_all_results(); $arr = $this->fpaginate->paginate($pagenum, $count); $data['startpage'] = $arr[0]; $data['endpage'] = $arr[1]; $start = $arr[2]; $perpage = $arr[3]; $data['count'] = $count; $this->db->where($field, $id); if (!empty($sortfield)) { $this->db->order_by($sortfield, $sorttype); } $data['results'] = $this->db->get($table); return $data; } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if ($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } function get_data_srow($table, $id, $field, $sortfield = "") { $data = array(); $this->db->where($field, $id); if (!empty($sortfield)) { $this->db->order_by($sortfield, 'asc'); } $Q = $this->db->get($table); $row = $Q->row(); return $row; } function deletedata($table, $field, $id) { $this->db->where($field, $id); $res = $this->db->delete($table); return $res; } function get_num_rows($table, $field, $value) { $this->db->where($field, $value); $Q = $this->db->get($table); return $Q->num_rows(); } function convertdateformat($date) { if ($date == "" || $date == "00-00-0000") { return ""; } else { $time = strtotime($date); return date('Y-m-d', $time); } } function convertdatenormalformat($date) { if ($date == "" || $date == "0000-00-00") { return ""; } else { $time = strtotime($date); return date('d-m-Y', $time); } } function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } function get_data_table($table, $id, $field, $sortfield = "") { $data = array(); $this->db->where($field, $id); if (!empty($sortfield)) { $this->db->order_by($sortfield, 'asc'); } $Q = $this->db->get($table); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_banner() { $data = array(); $this->db->select('*'); $this->db->from('banner'); $this->db->order_by('banner_sort', 'asc'); $data['results'] = $this->db->get(); return $data; } function get_news() { $data = array(); $this->db->select('*'); $this->db->from('news'); $this->db->order_by('news_date', 'desc'); $data = $this->db->get(); return $data->result_array(); } function get_client() { $data = array(); $this->db->select('*'); $this->db->from('client'); $this->db->order_by('client_sort', 'asc'); $data['results'] = $this->db->get(); return $data; } function get_directory() { $data = array(); $this->db->select('*'); $this->db->from('directory'); $this->db->order_by('directory_sort', 'asc'); $data = $this->db->get(); return $data->result_array(); } function get_gallery($id) { $this->db->select('*') ->from('gallery'); $this->db->where('directory_id', $id); $this->db->order_by('gallery_sort','asc'); $data = $this->db->get(); return $data->result_array(); } function insert_contact() { $data = array(); $this->db->trans_begin(); $name = $this->input->post('name'); $email = $this->input->post('email'); $telefon = $this->input->post('telefon'); $message = $this->input->post('message'); $tbl1Values = array( 'contact_name' => $name, 'contact_email' => $email, 'contact_phone' => $telefon, 'contact_message' => $message, ); $this->db->insert('contact', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } } ?>