%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Common_Model extends CI_Model { /* * Function : getAllRecordsGroupBy */ public function getAllRecordsGroupBy($tbl_name, $col = '*', $condition = null, $order_by = NULL, $limit = NULL, $start = NULL) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } if (!empty($order_by)) { foreach ($order_by as $key => $val) { $this->db->order_by($key, $val); } } $this->db->group_by('school_id'); if ($limit !== null && $start !== null) { $query = $this->db->get($tbl_name, $limit, $start); } else { $query = $this->db->get($tbl_name); } //echo $this->db->last_query(); die; $resutls = array(); foreach ($query->result_array() as $row) { $resutls[$row['school_id']] = $row['total']; } return $resutls; } /* * Function : getRecordsByGroup */ public function getRecordsByGroup($tbl_name = '', $col = '*', $condition = null, $group_by_column = 'school_id') { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } if (!empty($order_by)) { foreach ($order_by as $key => $val) { $this->db->order_by($key, $val); } } $this->db->group_by($group_by_column); $query = $this->db->get($tbl_name); //echo $this->db->last_query(); die; $resutls = array(); foreach ($query->result_array() as $row) { $resutls[$row[$group_by_column]] = $row['total']; } return $resutls; } /* * Function : getAllRecords */ public function getAllRecords($tbl_name, $col = ' * ', $condition = null, $order_by = NULL, $limit = NULL, $start = NULL) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } if (!empty($order_by)) { foreach ($order_by as $key => $val) { $this->db->order_by($key, $val); } } if ($limit !== null && $start !== null) { $query = $this->db->get($tbl_name, $limit, $start); } else { $query = $this->db->get($tbl_name); } //echo $this->db->last_query(); die; return $query->result_array(); } /* * Function : getAllModuleList */ public function getAllModuleList($tbl_name, $col = ' * ', $condition = null, $where_in = NULL, $where_key = 'id') { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); $this->db->where_in($where_key, $where_in); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } //$this->db->order_by('display_order', 'asc'); $query = $this->db->get($tbl_name); //echo $this->db->last_query(); die; return $query->result_array(); } /* * Function : getSingleRecord */ public function getSingleRecord($tbl_name, $col = ' * ', $condition = null) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } $query = $this->db->get($tbl_name); //echo $this->db->last_query(); die; return $query->row_array(); } /* * Function : validatelogin */ public function validatelogin($tbl_name, $col = ' * ', $condition = array()) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { if ($key == 'password') { $this->db->where($key, md5($val)); } else { $this->db->where($key, $val); } } } $query = $this->db->get($tbl_name); //echo $this->db->last_query(); die; return $query->row_array(); } /* /* * Function : getCommonQuery */ public function getCommon2Query($tbl_name = 'tbl_schools', $col = ' * ', $condition = '') { $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } $query = $this->db->get($tbl_name); echo $this->db->last_query(); die; return $query->result_array(); } /* * Function : getCommonQuery */ public function getCommonQuery($tbl_name = 'tbl_schools', $col = ' * ', $condition = '') { $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } $query = $this->db->get($tbl_name); return $query->result_array(); } public function saveinfo($tbl_name = '', $post) { $this->db->insert($tbl_name, $post); //echo $this->db->last_query(); die; return $this->db->insert_id(); } public function updateinfo($tbl_name = '', $post, $field, $value) { $this->db->where($field, $value); if (!$this->db->update($tbl_name, $post)) { log_message('error', print_r($this->db->error(), true)); } //echo $this->db->last_query(); die; } /* * Function: removeAllItems * Parameters: * Purpose: * CreatedOn: * CreatedBy: * ModifiedOn: * Modified By: * Return: */ public function removeAllItems($table_name = "", $user_id, $col_name = 'user_id') { if ($user_id > 0) { $this->db->where($col_name, $user_id); $this->db->delete($table_name); return true; } } /* * Function: encryptpassword * Parameters: * Purpose: * CreatedOn: * CreatedBy: * ModifiedOn: * Modified By: * Return: */ function encryptpassword($plainText) { $base64 = base64_encode($plainText); $base64url = strtr($base64, '+/=', '-_,'); return $base64url; } /* * Function: decryptpassword * Parameters: * Purpose: * CreatedOn: * CreatedBy: * ModifiedOn: * Modified By: * Return: */ function decryptpassword($plainText) { $base64url = strtr($plainText, '-_,', '+/='); $base64 = base64_decode($base64url); return $base64; } /* * Function: getSchoolList * Parameters: * Purpose: * CreatedOn: * CreatedBy: * ModifiedOn: * Modified By: * Return: */ public function getCommonIdArray($tbl_name = 'tbl_schools', $col = ' * ', $condition = null) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } //$this->db->order_by('id', 'asc'); $query = $this->db->get($tbl_name); $results = array(); foreach ($query->result_array() as $row) { $results[$row['id']] = $row; } return $results; } /* * Function: getCommonSingleRecord * Parameters: * Purpose: * CreatedOn: * CreatedBy: * ModifiedOn: * Modified By: * Return: */ public function getCommonSingleRecord($tbl_name = 'tbl_schools', $col = ' * ', $condition = null) { $this->db->select($col); $this->db->where('status', '1'); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } $query = $this->db->get($tbl_name); $results = array(); $results = $query->row_array(); return $results; } public function getAllRecordscount($tbl_name, $col = ' * ', $condition = null, $order_by = NULL, $limit = NULL, $start = NULL) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } if (!empty($order_by)) { foreach ($order_by as $key => $val) { $this->db->order_by($key, $val); } } if ($limit !== null && $start !== null) { $query = $this->db->get($tbl_name, $limit, $start); } else { $query = $this->db->get($tbl_name); } //echo $this->db->last_query(); die; return $query->num_rows(); } // Function for deletion public function deleterecords($tbl_name, $id) { if ($tbl_name != '' && $id > 0) { $sql_query = $this->db->where('id', $id)->delete($tbl_name); } } /* * Function : getAllDigitsNumber */ public function getAllDigitsNumber($number) { $no_of_digit = 7; $length = strlen((string)$number); for ($i = $length; $i < $no_of_digit; $i++) { $number = '0' . $number; } return $number; } /* * Function: getCommonstatsArray * Parameters: * Purpose: * CreatedOn: * CreatedBy: * ModifiedOn: * Modified By: * Return: */ public function getCommonstatsArray($tbl_name = 'tbl_stats_master', $col = ' * ', $condition = null) { $time = time(); $this->db->select($col); $this->db->where('is_deleted', '0'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } //$this->db->order_by('id', 'asc'); $query = $this->db->get($tbl_name); $menteesArray = $query->result_array(); $results = array(); foreach ($menteesArray as $val) { $results[$val['admin_id']] = $val; } return $results; } public function getlatestdata($tbl_name, $col = "*", $max_col, $condition = null) { $this->db->select($col); $this->db->where('is_deleted', '0'); $this->db->where($max_col . '=(SELECT MAX(' . $max_col . ') FROM ' . $tbl_name . ')'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } $query = $this->db->get($tbl_name); //echo $this->db->last_query(); die; return $query->row_array(); } public function getAllshardastories($tbl_name, $col = "*", $max_col, $condition = null, $order_by = NULL, $limit = NULL, $start = NULL) { $this->db->select($col); $this->db->where('is_deleted', '0'); $this->db->where($max_col . '!=(SELECT MAX(' . $max_col . ') FROM ' . $tbl_name . ')'); if (!empty($condition)) { foreach ($condition as $key => $val) { $this->db->where($key, $val); } } if (!empty($order_by)) { foreach ($order_by as $key => $val) { $this->db->order_by($key, $val); } } if ($limit !== null && $start !== null) { $query = $this->db->get($tbl_name, $limit, $start); } else { $query = $this->db->get($tbl_name); } //echo $this->db->last_query(); die; return $query->result_array(); } /* * Function : getLeadershipDetails */ public function getLeadershipDetails($slug) { $time = time(); $this->db->select('*'); $this->db->where('is_deleted', '0'); $this->db->where('status', '1'); $this->db->order_by('display_order', 'asc'); $query = $this->db->get('tbl_leadership'); //echo $this->db->last_query(); die; $responseArray = $query->result_array(); $results = array(); foreach ($responseArray as $value) { if (strtolower($value['slug']) == strtolower($slug)) { $results['activeRecord'] = $value; } } $results['response'] = $responseArray; return $results; } }