BBnepal-Accounts/application/models/Student_model.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

842 lines
31 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
use Nilambar\NepaliDate\NepaliDate;
require_once 'vendor/autoload.php';
class Student_model extends CI_Model
{
private $nepaliDateObject;
private $nepali_current_date;
public function __construct()
{
$this->load->database();
$this->load->library('Ciqrcode');
$this->load->helper('common_helper');
date_default_timezone_set("Asia/Kolkata");
$this->nepaliDateObject = new NepaliDate();
$this->nepali_current_date = cuurentNepaliDate($this->nepaliDateObject);
}
public function login($uname, $pwd)
{
$pwd = md5($pwd);
$sql = $this->db->query("SELECT * FROM students WHERE studentId='$uname' AND password='$pwd'");
// echo $this->db->last_query($sql);
if ($sql->num_rows() > 0) {
if ($sql->row()->is_active == 'yes') {
return $sql->row_object();
} else {
return false;
}
} else {
return false;
}
}
public function get_studentMenus()
{
$this->db->select('*');
$this->db->from('student_menu');
$this->db->where('is_active', 'yes');
$this->db->order_by('id', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_courses()
{
$this->db->select('*');
$this->db->from('course');
$this->db->where('is_active', 'yes');
$this->db->order_by('course_name', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
//shankar code
public function get_batch()
{
$this->db->select('*');
$this->db->from('batch');
$this->db->order_by('id', 'DESC');
$query = $this->db->get();
return $query->result_array();
}
//end shankar code
public function add_applicationinfo($data)
{
$inf = $data['sinfo'];
$photo = $data['photo'];
$medical = $data['medical'];
$school = $data['school'];
$exam = $data['exam'];
$this->db->select_max('id');
$query = $this->db->get('applications');
$res = $query->row_array();
$pid = $res['id'] + 1;
// if (strlen($pid) == 1)
// $pid = "000" . $pid;
// else if (strlen($pid) == 2)
// $pid = "00" . $pid;
// else if (strlen($pid) == 3)
// $pid = "0" . $pid;
$school_info = $this->get_logo_from_setting();
$school_prefix = (!empty($school_info['school_prefix_id'])) ? $school_info['school_prefix_id'] : 'BB';
$applicationid = $school_prefix . STUDENT_APPLICATION_PREFIX . date('Y', strtotime($this->nepali_current_date)) . '0' . $pid;
$indata = array(
'name' => $inf['sfname'] . ' ' . $inf['ssname'],
'applicationid' => $applicationid,
'email' => $inf['semail'],
'mobile' => $inf['scontact'],
'password' => md5($inf['spaswd']),
'gender' => $inf['sgender'],
'dob' => $inf['sdob'],
'course' => $inf['scourse'],
'batch_id' => $inf['sbatch'],
'emergency_contact_name' => $inf['lgfullname'],
'emergency_contact_number' => $inf['lgcontact'],
'emergency_contact_address' => $inf['lgaddress'],
'birth_certificate' => $inf['sbirth-certificate'],
'caste' => $inf['scaste'],
'religion' => $inf['sreligion'],
'previous_school' => $inf['sprevious-school'],
'father_name' => $inf['sfathername'],
'father_citizenship' => $inf['fcitizenship-number'],
'father_mobile' => $inf['fcontact'],
'mother_name' => $inf['mfathername'],
'mother_citizenship' => $inf['mcitizenship-number'],
'mother_mobile' => $inf['mcontact'],
'country' => $inf['scountry'],
'state' => $inf['sprovince'],
'address1' => $inf['saddress'],
'address2' => '',
'zipcode' => '',
'school_certificate' => $school,
'exam_result' => $exam,
'photo' => $photo,
'medical_cerificate' => $medical,
'payment_method' => 'cash',
'description' => '',
'registered_on' => $this->nepali_current_date
);
$insert = $this->db->insert('applications', $indata);
$newId = $this->db->insert_id();
$result = (!empty($newId)) ? $newId : 0;
return $result;
}
public function storeTransaction($data)
{
$result = $this->db->insert('student_online_transactions', $data);
return $result;
}
public function storefeeTransaction($data)
{
$result = $this->db->insert('student_fee_online_transactions', $data);
return $result;
}
public function applications_get($data, $feestyId)
{
$courseId = (isset($data['course']) && !empty($data['course'])) ? $data['course'] : 0;
$batchId = (isset($data['batch_id']) && !empty($data['batch_id'])) ? $data['batch_id'] : 0;
$this->db->select('*');
$this->db->from('course_fees');
$this->db->where('course_id', $courseId);
$this->db->where('batch_id', $batchId);
$this->db->where('fees_type', $feestyId);
$query = $this->db->get();
return $query->row_array();
}
public function installment_get($course)
{
$this->db->select('*');
$this->db->from('installment');
$this->db->where('course_id', $course);
$query = $this->db->get();
//echo $this->db->last_query();
return $query->result_array();
}
public function install_get($install_type_id)
{
$this->db->select('*');
$this->db->from('installment');
$this->db->where('id', $install_type_id);
$query = $this->db->get();
//echo $this->db->last_query();
return $query->row_array();
}
public function updateapplication($data)
{
$update = array(
'payment_status' => $data['payment_status'],
);
$this->db->where('id', $data['product_id']);
$update = $this->db->update('applications', $update);
// echo $this->db->last_query();
}
// Moving application info to students -start - by shivakumar
public function applicationinfo_movingto_students($applicationId)
{
$this->db->select('*');
$this->db->from('applications');
$this->db->where('id', $applicationId);
$query = $this->db->get();
$res = $query->row_array();
$appdata = (!empty($res)) ? $res : 0;
if ($appdata != 0) {
if ($appdata['status'] == 'moved') {
return -1;
} else {
$this->db->select_max('id');
$query = $this->db->get('students');
$resid = $query->row_array();
$resid = (isset($resid['id']) && !empty($resid['id'])) ? $resid['id'] : 0;
$studentMaxId = $resid + 1;
// if (strlen($studentMaxId) == 1)
// $pid = "00000" . $studentMaxId;
// else if (strlen($studentMaxId) == 2)
// $pid = "0000" . $studentMaxId;
// else if (strlen($studentMaxId) == 3)
// $pid = "000" . $studentMaxId;
// else if (strlen($studentMaxId) == 4)
// $pid = "00" . $studentMaxId;
// else if (strlen($studentMaxId) == 5)
// $pid = "00" . $studentMaxId;
$pid = date('Y', strtotime($this->nepali_current_date)) . '0' . $studentMaxId;
$school_info = $this->get_logo_from_setting();
$school_prefix = (!empty($school_info['school_prefix_id'])) ? $school_info['school_prefix_id'] : 'BB';
$studentid = $school_prefix . STUDENT_PREFIX . $pid;
$parent_id = $school_prefix . STUDENT_PARENT_PREFIX . $pid;
$qr_path = $this->generate_qrcode($studentid);
$insertdata = array(
'id' => $studentMaxId,
'name' => $appdata['name'],
'studentId' => $studentid,
'course' => $appdata['course'],
'batch_id' => $appdata['batch_id'],
'email' => $appdata['email'],
'password' => $appdata['password'],
'mobile' => $appdata['mobile'],
'gender' => $appdata['gender'],
'dob' => $appdata['dob'],
'emergency_contact_name' => $appdata['emergency_contact_name'],
'emergency_contact_number' => $appdata['emergency_contact_number'],
'country' => $appdata['country'],
'state' => $appdata['state'],
'address1' => $appdata['address1'],
'address2' => $appdata['address2'],
'zipcode' => $appdata['zipcode'],
'photo' => $appdata['photo'],
'school_certificate' => $appdata['school_certificate'],
'exam_result' => $appdata['exam_result'],
'medical_cerificate' => $appdata['medical_cerificate'],
'payment_status' => $appdata['payment_status'],
'registered_on' => date('Y-m-d H:i:s', strtotime($this->nepali_current_date)),
'assign_status' => 'no',
'qr_code' => $qr_path,
'parent_username' => $parent_id,
'parent_password' => md5($parent_id),
'is_active' => 'yes'
);
$insert = $this->db->insert('students', $insertdata);
if ($insert) {
$update = array(
'status' => 'moved',
);
$this->db->where('id', $applicationId);
$this->db->update('applications', $update);
return $studentMaxId;
} else {
return "failed";
}
}
}
}
public function generate_qrcode($studentID)
{
$hex_data = date('YmdHis', strtotime($this->nepali_current_date)) . '-' . $studentID;
$save_name = $hex_data . '.png';
$dir = 'assets_student/studentqrcode/';
if (!file_exists($dir)) {
mkdir($dir, 0775, true);
}
/* QR Configuration */
$config['cacheable'] = true;
$config['imagedir'] = $dir;
$config['quality'] = true;
$config['size'] = '1024';
$config['black'] = array(255, 255, 255);
$config['white'] = array(255, 255, 255);
$this->ciqrcode->initialize($config);
/* QR Data */
$params['data'] = $studentID;
$params['level'] = 'L';
$params['size'] = 10;
$params['savename'] = $config['imagedir'] . $save_name;
$result = $this->ciqrcode->generate($params);
return $result;
}
// Moving application info to students -end - by shivakuamr
public function move_applicationinfo($appid)
{
$this->db->select('*');
$this->db->from('applications');
$this->db->where('id', $appid);
$query = $this->db->get();
$res = $query->result_array();
// echo $this->db->last_query();
foreach ($res as $r) {
$appStatus = $r['status'];
}
if ($r['status'] == "moved") {
return -1;
} else {
$this->db->select_max('id');
$query = $this->db->get('students');
$resid = $query->row_array();
$pid = $resid['id'] + 1;
if (strlen($pid) == 1)
$pid = "00000" . $pid;
else if (strlen($pid) == 2)
$pid = "0000" . $pid;
else if (strlen($pid) == 3)
$pid = "000" . $pid;
else if (strlen($pid) == 4)
$pid = "00" . $pid;
else if (strlen($pid) == 5)
$pid = "00" . $pid;
$studentid = "ECS" . date('Y', strtotime($this->nepali_current_date)) . $pid;
// print_r($res);
foreach ($res as $r) {
$name = $r['name'];
$applicationid = $r['applicationid'];
$email = $r['email'];
$mobile = $r['mobile'];
$password = $r['password'];
$gender = $r['gender'];
$dob = $r['dob'];
$course = $r['course'];
$emergency_contact_name = $r['emergency_contact_name'];
$emergency_contact_number = $r['emergency_contact_number'];
$country = $r['country'];
$state = $r['state'];
$address1 = $r['address1'];
$address2 = $r['address2'];
$zipcode = $r['zipcode'];
$school_certificate = $r['school_certificate'];
$exam_result = $r['exam_result'];
$photo = $r['photo'];
$medical_cerificate = $r['medical_cerificate'];
$registered_on = $r['registered_on'];
$payment_status = "Success";
}
$s = array(
'name' => $name,
'studentId' => $studentid,
'email' => $email,
'mobile' => $mobile,
'password' => $password,
'gender' => $gender,
'dob' => $dob,
'course' => $course,
'emergency_contact_name' => $emergency_contact_name,
'emergency_contact_number' => $emergency_contact_number,
'country' => $country,
'state' => $state,
'address1' => $address1,
'address2' => $address2,
'zipcode' => $zipcode,
'school_certificate' => $school_certificate,
'exam_result' => $exam_result,
'photo' => $photo,
'medical_cerificate' => $medical_cerificate,
'registered_on' => $registered_on,
'payment_status' => $payment_status
);
// print_r($s);
$insert = $this->db->insert('students', $s);
$newId = $this->db->insert_id();
$update = array(
'status' => 'moved',
);
$this->db->where('id', $appid);
$update = $this->db->update('applications', $update);
// echo $this->db->last_query();
return $studentid;
}
}
public function get_myClasses($id)
{
$nowMonth = date('m', strtotime($this->nepali_current_date));
$nowYear = date('Y', strtotime($this->nepali_current_date));
$nowDay = date('d', strtotime($this->nepali_current_date));
$obj = new NepaliDate();
// Convert BS to AD.
$nowArr = $obj->convertBsToAd($nowYear, $nowMonth, $nowDay);
$currConvDate = $nowArr['year'] . '-' . $nowArr['month'] . '-' . $nowArr['day'];
$pday = strtolower(date('l', strtotime($currConvDate)));
$query = "select classroom.id,classroom_name,classroom_session.id,session_details.subject_id,subject_name,start,join_link, classroom.classroom_name,day,duration
from
students
left join classroom on students.classroom = classroom.id
left join classroom_session on classroom_session.classroom_id = classroom.id
left join session_details on session_details.session_id = classroom_session.id
left join subject on subject.id = session_details.subject_id
where
students.id = " . $id . " and day = '" . $pday . "'";
$q = $this->db->query($query);
// echo $this->db->last_query();
return $q->result_array();
}
public function get_mydayClasses($id, $pday)
{
$query = "select classroom.id,classroom_name,classroom_session.id,session_details.subject_id,subject_name,subject_icon,start,join_link, classroom.classroom_name,day,duration
from
students
left join classroom on students.classroom = classroom.id
left join classroom_session on classroom_session.classroom_id = classroom.id
left join session_details on session_details.session_id = classroom_session.id
left join subject on subject.id = session_details.subject_id
where
students.id= " . $id . " and day = '" . $pday . "' order by day,start asc";
$q = $this->db->query($query);
//echo $this->db->last_query();
return $q->result_array();
}
public function get_teacher($sid, $cname)
{
$query = "select teacher_name,photo from classroom,teacher where classroom.subject_id = " . $sid . " and classroom_name = '" . $cname . "' and classroom.teacher_id =teacher.id";
$q = $this->db->query($query);
// echo $this->db->last_query();
return $q->result_array();
}
/*********************************/
//-----shankar code of assignment starts from here---//
/******************************* */
public function get_assignment_list($student_id, $asgn_id = '', $month = '', $year = '')
{
if ($asgn_id == 0 || empty($asgn_id)) {
$this->db->select('a.id as assignment_id, a.classroom_id, a.teacher_id, a.subject_id, a.title, a.remark, a.due_date, t.teacher_name, s.subject_name,s.subject_icon');
$this->db->from('assignment a, subject s, teacher t, students stu, student_batch sb');
$this->db->where('stu.id', $student_id);
$this->db->where('stu.id = sb.student_id');
$this->db->where('stu.batch_id = sb.batch_id');
$this->db->where('sb.classroom_id = a.classroom_id');
// $this->db->where('a.subject_id', $val);
$this->db->where('a.subject_id = s.id');
$this->db->where('a.teacher_id = t.id');
if ($month != 00 || $year != 0) {
$this->db->where("DATE_FORMAT(due_date,'%m')", $month);
$this->db->where("DATE_FORMAT(due_date,'%Y')", $year);
}
$this->db->order_by('a.id desc');
$query = $this->db->get();
return $query->result_array();
} else {
$this->db->select('a.id as assignment_id, a.classroom_id, a.teacher_id, a.subject_id, a.title, a.remark, a.due_date, t.teacher_name, s.subject_name, s.subject_icon');
$this->db->from('assignment a, subject s, teacher t');
$this->db->where('a.id', $asgn_id);
$this->db->where('a.subject_id = s.id');
$this->db->where('a.teacher_id = t.id');
if ($month != 00 || $year != 0) {
$this->db->where("DATE_FORMAT(due_date,'%m')", $month);
$this->db->where("DATE_FORMAT(due_date,'%Y')", $year);
}
$query = $this->db->get();
return $query->result_array();
}
}
public function upload_assignment($data)
{
$check = $this->db->query('select id from assignments_uploaded where Path= "' . $data['Path'] . '"');
$res = $check->result_array();
if ($res) {
$data['modified'] = $this->nepali_current_date;
$this->db->where('id', $res[0]['id']);
$this->db->update('assignments_uploaded', $data);
return true;
} else {
$data['created'] = $this->nepali_current_date;
$this->db->insert('assignments_uploaded', $data);
return true;
}
}
public function uploaded_assignent($student_id, $asgn_id)
{
$this->db->select('*');
$this->db->from('assignments_uploaded');
$this->db->where('student_id', $student_id);
$this->db->where('assignment_id', $asgn_id);
$query = $this->db->get();
return $query->result_array();
}
public function upload_assignment_submit($data)
{
$this->db->where('assignment_id', $data['assignment_id']);
$this->db->where('student_id', $data['student_id']);
$this->db->update('assignments_uploaded', $data);
return true;
}
public function upload_assignment_cancel($asgn_id, $student_id)
{
$this->db->where('assignment_id', $asgn_id);
$this->db->where('student_id', $student_id);
$this->db->delete('assignments_uploaded');
return true;
}
/**********************************************/
//-----shankar code of assignment end ---//
/**********************************************/
// Notification models - 13-10-2021
public function getStudentNotification($id, $date)
{
$query = "SELECT students.name, students.email,classroom.id as classroom_id, classroom.classroom_name, classroom.course_id
FROM students
INNER JOIN student_batch sb ON students.id = sb.student_id
AND sb.batch_id = students.batch_id
INNER JOIN classroom ON sb.classroom_id = classroom.id
WHERE students.id = $id";
$res = $this->db->query($query);
if ($res->num_rows() > 0) {
$month = $date['month'];
$year = $date['year'];
$classRoomId = $res->row()->classroom_id;
$notRes = $this->db->query("Select * from notifications where (notification_to = 'student' OR notification_to = 'both') AND ((month(created_at)= '$month') AND (year(created_at) = '$year')) AND student_classroom = '$classRoomId' ORDER BY notification_id DESC");
if ($notRes->num_rows() > 0) {
return $notRes->result_array();
} else {
return false;
}
} else {
return false;
}
}
public function getAllStudentNotification($id, $notif_id = '')
{
$query = "SELECT students.name, students.email,classroom.id as classroom_id, classroom.classroom_name, classroom.course_id FROM students INNER JOIN student_batch sb ON students.id = sb.student_id AND students.batch_id = sb.batch_id INNER JOIN classroom ON sb.classroom_id = classroom.id WHERE students.id = $id";
$res = $this->db->query($query);
if ($res->num_rows() > 0) {
$classRoomName = $res->row()->classroom_id;
if ($notif_id != '') {
$where = "n.notification_id = $notif_id";
} else {
$where = "n.student_classroom = '$classRoomName'";
}
$notRes = $this->db->query("Select n.*, t.teacher_name from notifications n left join teacher t on n.teacher_id = t.id where $where ORDER BY n.notification_id DESC");
if ($notRes->num_rows() > 0) {
$notRes = $notRes->result_array();
foreach ($notRes as $key => $value) {
$notRes[$key]['teacher_id'] = $value['teacher_id'] ? $value['teacher_id'] : '';
}
return $notRes;
} else {
return false;
}
} else {
return false;
}
}
public function getSingleNotification($id)
{
$query = $this->db->query('SELECT * FROM notifications WHERE notification_id = ' . $id);
if ($query->num_rows() > 0) {
$result = $query->row();
return $result;
} else {
return 'failed';
}
}
// Notification Models End - 13-10-2021
//shankar code of Student Syllybus Models start - 29-10-2021
public function get_student_syllabus($student_id)
{
$this->db->select('student_id, subject_id, subject_name, classroom.course_id, syllabus,subject_icon, subject_syllabus.id as subject_syllabus_id');
$this->db->from('students , classroom, subject_syllabus, student_batch, subject');
$this->db->where('students.id', $student_id);
$this->db->where('student_batch.batch_id = students.batch_id');
$this->db->where('students.id = student_batch.student_id');
$this->db->where('student_batch.classroom_id = classroom.id');
$this->db->where('subject_syllabus.course_id = classroom.course_id');
$this->db->where('subject.id = subject_syllabus.subject_id');
$this->db->group_by('subject_syllabus.subject_id');
$query = $this->db->get();
return $query->result_array();
}
//shankar code of Student Syllybus Models end - 29-10-2021
// Student Attendance - 03-11-21 Afras Khan
public function get_table_info($table_name, $where = '', $sqlQry = '', $order = 'DESC', $limit = FALSE, $offset = FALSE)
{
if ($limit)
$this->db->limit($limit, $offset);
if ($where != '')
$this->db->where($where);
$this->db->order_by($table_name . '.id', $order);
$query = $this->db->get($table_name);
if ($sqlQry != '')
$query = $this->db->query($sqlQry);
return $query->result_array();
}
public function get_student_attendance($where)
{
$this->db->select('student_id, classroom_id, subject_id, DATE_FORMAT(attendence_date, "%d/%m/%Y") as date, status, attendence_date, DATE_FORMAT(attendence_date,"%r") as time');
$this->db->where($where);
$this->db->order_by('DAY(attendence_date)', 'ASC');
$query = $this->db->get('student_attendence');
return $query->result_array();
}
// Student Attendance End - 03-11-21 Afras Khan
//Start code of Up- Coming Test/Exams 08-11-21 - Shankar
public function upcoming_Test_or_Exams($student_id, $exam_que_id = '')
{
$this->db->select('questions.id as question_id, exam_id, e_name, classroom_id, classroom_name, subject_id, subject_name, exam_date, exam_starttime, exam_endtime, total_marks ');
$this->db->from('classroom, student_batch,students, subject, questions,exam');
if ($exam_que_id == '' || empty($exam_que_id)) {
$this->db->where('students.id', $student_id);
$this->db->where('students.id = student_batch.student_id');
$this->db->where('students.batch_id = student_batch.batch_id');
$this->db->where('student_batch.classroom_id = classroom.id');
$this->db->where('exam_date >=', date('Y-m-d', strtotime($this->nepali_current_date)));
} else {
$this->db->where('questions.id', $exam_que_id);
}
$this->db->where('classroom.course_id = questions.course_id');
$this->db->where('questions.exam_id = exam.id');
$this->db->where('subject.id = questions.subject_id');
$this->db->group_by('questions.id');
$query = $this->db->get();
// echo $this->db->last_query();
return $query->result_array();
}
public function get_allQuestions($que_exam_id)
{
$query = 'SELECT option_a , option_b , option_c , option_d , question_type_id , question_name, exam_questions.id as id , questions.course_id, questions.exam_date, questions.exam_starttime,question_name, questions.exam_endtime,exam_questions.image,subject_name, e_name, questions.id as test_id, exam_questions.question_mark as marks from exam_questions
LEFT JOIN questions ON questions.id = exam_questions.exam_id
LEFT JOIN subject ON exam_questions.subject_id = subject.id
LEFT JOIN exam ON exam.id = questions.exam_id
where exam_questions.exam_id = ' . $que_exam_id . ' order by exam_questions.id asc';
$q = $this->db->query($query);
// echo $this->db->last_query();
return $q->result_array();
}
public function storeAnswer($ans_array_json, $student_id)
{
$ans_array = json_decode($ans_array_json, true);
$length = count($ans_array);
$i = 0;
$response = 0;
for ($i = 0; $i < $length; $i++) {
$ans_array[$i]['created'] = $this->nepali_current_date;
$this->db->insert('exam_answers', $ans_array[$i]);
$res = $this->db->insert_id();
$query = $this->db->query('select ea.answer, eq.correct_answer, eq.question_mark from exam_questions eq, exam_answers ea where ea.id=' . $res . ' and ea.exam_questions_id = eq.id');
$data = $query->row_array();
if ($data['answer'] == $data['correct_answer']) {
$this->db->set('review', $data['question_mark']);
} else if ($data['correct_answer'] == '') {
$this->db->set('review', '');
} else {
$this->db->set('review', 0);
}
$this->db->set('modified', $this->nepali_current_date);
$this->db->where('id', $res);
$this->db->update('exam_answers');
$updated_status = $this->db->affected_rows();
if ($updated_status) {
$response = 1;
}
}
return $response;
}
//End code of Up- Coming Test/Exams 10-11-21 - Shankar
// to get application fee by shivu -start
public function get_query_result($sqlQry)
{
if ($sqlQry != '')
$query = $this->db->query($sqlQry);
return $query->result_array();
}
public function get_query_row($sqlQry)
{
if ($sqlQry != '')
$query = $this->db->query($sqlQry);
return $query->row_array();
}
public function get_general_row_details($table_name, $where = '', $sqlQry = '', $order_by = 'ASC', $limit = FALSE, $offset = FALSE)
{
if ($limit)
$this->db->limit($limit, $offset);
if ($where != '')
$this->db->where($where);
$this->db->order_by($table_name . '.id', $order_by);
$query = $this->db->get($table_name);
if ($sqlQry != '')
$query = $this->db->query($sqlQry);
return $query->row_array();
}
// to get application fee by shivu -end
// Hostel Afras Khan
function add_edit_table($table, $id, $data, $update_where = '')
{
if ($id == 0) {
$this->db->insert($table, $data);
if ($this->db->affected_rows() > 0)
return $insert_id = $this->db->insert_id();
else
return 0;
} else {
if ($update_where != '')
$this->db->where($update_where);
else
$this->db->where('id', $id);
$this->db->update($table, $data);
if ($this->db->trans_status() === FALSE)
return 0;
return true;
}
}
// Hostel End
//getStudent_id from user_api
public function getStudentId($id)
{
$result = $this->db->query('select id,studentId from students where studentId = "' . $id . '"')->row_array();
return $result;
}
public function get_logo_from_setting()
{
$this->db->select('*');
$this->db->from('school_settings');
$query = $this->db->get();
return $query->row_array();
}
}