KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
User : www-data ( 33)
PHP Version : 8.2.12
Disable Function : NONE
Directory :  /var/www/parasoffline.edukrypt.in/application/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/parasoffline.edukrypt.in/application/models/Main_model.php
<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Main_model extends CI_Model
{

	public function insert($table, $insert_data)
	{
		$this->db->trans_start();
		$this->db->insert($table, $insert_data);
		$this->db->trans_complete();

		if ($this->db->trans_status() === TRUE) {
			$this->db->trans_commit();

			return true;
		} else {
			$this->db->trans_rollback();
		}

		return false;
	}

	public function update($table, $update_data, $conditions)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		$this->db->trans_start();
		$this->db->set($update_data);

		foreach ($conditions as $key => $condition) {
			$this->db->where($key, $condition);
		}

		$this->db->update($table);
		$this->db->trans_complete();

		if ($this->db->trans_status() === TRUE) {
			$this->db->trans_commit();

			return true;
		} else {
			$this->db->trans_rollback();
		}

		return false;
	}

	public function get($table, $select = NULL, $order_by_conditions = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		if (!empty($order_by_conditions)) {
			foreach ($order_by_conditions as $key => $condition) {
				$this->db->order_by($key, $condition);
			}
		}
		$query = $this->db->get($table);
		// return $this->db->last_query();
		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return array();
	}

	public function get_where($table, $col, $match, $select = NULL, $order_by_conditions = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		$this->db->where($col, $match);
		if (!empty($order_by_conditions)) {
			foreach ($order_by_conditions as $key => $condition) {
				$this->db->order_by($key, $condition);
			}
		}


		$query = $this->db->get($table);
		// return $this->db->last_query();

		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return array();
	}

	public function get_where_as($table, $conditions, $select = NULL, $order_by_conditions = NULL)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		if (!empty($select)) {
			$this->db->select($select);
		}

		foreach ($conditions as $key => $condition) {
			$this->db->where($key, $condition);
		}

		if (!empty($order_by_conditions) && is_array($conditions)) {
			foreach ($order_by_conditions as $key => $condition) {
				$this->db->order_by($key, $condition);
			}
		}

		$query = $this->db->get($table);
		// return $this->db->last_query();
		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return array();
	}

	public function get_where_total_rows($table, $conditions, $select = NULL)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		if (!empty($select)) {
			$this->db->select($select);
		}

		foreach ($conditions as $key => $condition) {
			$this->db->where($key, $condition);
		}

		$query = $this->db->get($table);
		// return $this->db->last_query();
		return $query->num_rows();
	}


	public function delete($table, $conditions)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		$this->db->trans_start();

		foreach ($conditions as $key => $condition) {
			$this->db->where($key, $condition);
		}

		$this->db->delete($table);
		$this->db->trans_complete();

		if ($this->db->trans_status() === TRUE) {
			$this->db->trans_commit();

			return true;
		} else {
			$this->db->trans_rollback();
		}

		return false;
	}

	public function get_where_not_in($table, $col, $match, $select = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		$this->db->where_not_in($col, $match);
		$query = $this->db->get($table);

		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return array();
	}

	public function get_where_in($table, $col, $match, $select = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		$this->db->where_in($col, $match);
		$query = $this->db->get($table);

		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return array();
	}


	public function check_data_exist($table, $col, $match, $select = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		$this->db->where($col, $match);
		$query = $this->db->get($table);

		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return array();
	}

	public function getSearchData($table, $like, $search_data, $select = NULL, $_or_like = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		$this->db->like($like, $search_data);
		if (!empty($_or_like)) {
			$this->db->or_like($_or_like, $search_data);
		}
		$query = $this->db->get($table);
		return $query->result();
	}

	public function getTotalRows($table, $select = NULL)
	{
		if (!empty($select)) {
			$this->db->select($select);
		}

		$query = $this->db->get($table);

		return $query->num_rows();
	}

	/*get date by limit and order*/
	public function getLimitOrderBy($table, $limit, $start, $col, $dir)
	{
		$query = $this
			->db
			->limit($limit, $start)
			->order_by($col, $dir)
			->get($table);

		if ($query->num_rows() > 0) {
			return $query->result();
		} else {
			return null;
		}
	}


	function posts_search($table, $like, $search, $conditions, $where_conditons = NULL, $select = NULL, $limit = NULL, $start = NULL, $order = NULL, $dir = NULL)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		if (!empty($select)) {
			$this->db->select($select);
		}

		if (!empty($like) && !empty($search)) {
			$this->db->like($like, $search);
		}

		if (!empty($conditions)) {
			foreach ($conditions as $key => $condition) {
				$this->db->or_like($key, $condition);
			}
		}

		if (!empty($where_conditons)) {
			foreach ($where_conditons as $key1 => $condition1) {
				$this->db->where($key1, $condition1);
			}
		}


		if (!empty($limit) && !empty($start)) {
			$this->db->limit($limit, $start);
		}

		if (!empty($col) && !empty($dir)) {
			$this->db->limit($limit, $start);
		}

		$query = $this->db->get($table);
		// return $this->db->last_query();
		if ($query->num_rows() > 0) {
			return $query->result();
		} else {
			return null;
		}
	}

	function posts_search_count($table, $like, $search, $conditions, $where_conditons = NULL, $select = NULL, $limit = NULL, $start = NULL, $order = NULL, $dir = NULL)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		if (!empty($select)) {
			$this->db->select($select);
		}

		if (!empty($like) && !empty($search)) {
			$this->db->like($like, $search);
		}


		foreach ($conditions as $key => $condition) {
			$this->db->or_like($key, $condition);
		}

		if (!empty($where_conditons)) {
			foreach ($where_conditons as $key1 => $condition1) {
				$this->db->where($key1, $condition1);
			}
		}


		if (!empty($limit) && !empty($start)) {
			$this->db->limit($limit, $start);
		}

		if (!empty($col) && !empty($dir)) {
			$this->db->limit($limit, $start);
		}

		$query = $this->db->get($table);
		return $query->num_rows();
	}


	/*where conditon*/
	public function getLimitWhereOrderBy($table, $conditions, $limit, $start, $col, $dir, $select = NULL)
	{
		if (empty($table) || empty($conditions) || !is_array($conditions)) {
			return false;
		}

		if (!empty($select)) {
			$this->db->select($select);
		}

		foreach ($conditions as $key => $condition) {
			$this->db->where($key, $condition);
		}

		if (!empty($limit) && !empty($start)) {

			$this->db->limit($limit, $start);
		}

		if (!empty($col) && !empty($dir)) {

			$this->db->order_by($col, $dir);
		}


		$query = $this->db->get($table);
		// return $this->db->last_query();		
		if ($query->num_rows() > 0) {
			return $query->result();
		}

		return false;
	}



	// MCQ ===================

	public function allsubjectposts_count($table, $cid, $fid)
	{
		$query = $this
			->db
			->where($fid, $cid)
			->get($table);

		return $query->num_rows();
	}
	
	

	public function allsubjectposts($limit, $start, $col, $dir, $table, $cid, $fid)
	{
		$query = $this
			->db
			->where($fid, $cid)
			->limit($limit, $start)
			->order_by($col, $dir)
			->get($table);

		if ($query->num_rows() > 0) {
			return $query->result();
		} else {
			return [];
		}
	}
	
	public function all_subject_posts_count($table, $cid, $fid)
	{
		$query = $this
			->db
			->select('quiz_questions.*,mcq_subjects.id as mcq_sub_id, mcq_subjects.subject as m_subject')
			->from('quiz_questions')
			->join("mcq_subjects", "mcq_subjects.id = quiz_questions.subject_id")
			->where($fid, $cid)
			->get();

		return $query->num_rows();
	}
	
	public function all_subject_posts($limit, $start, $col, $dir, $table, $cid, $fid)
	{
		$query = $this
			->db
			->select('quiz_questions.*,mcq_subjects.id as mcq_sub_id, mcq_subjects.subject as m_subject')
			->from('quiz_questions')
			->join("mcq_subjects", "mcq_subjects.id = quiz_questions.subject_id")
			->where($fid, $cid)
			->limit($limit, $start)
			->order_by($col, $dir)
			->get();

		if ($query->num_rows() > 0) {
			return $query->result();
		} else {
			return [];
		}
	}


	public function posts_subj_search_count($search, $table, $title, $cid, $fid)
	{
		$query = $this
			->db
			->where($fid, $cid)
			->like('id', $search)
			->or_like($title, $search)
			->get($table);

		return $query->num_rows();
	}

	public function posts_subj_search($limit, $start, $search, $col, $dir, $table, $title, $cid, $fid)
	{
		$query = $this
			->db
			->where($fid, $cid)
			->like('id', $search)
			->or_like($title, $search)
			->limit($limit, $start)
			->order_by($col, $dir)
			->get($table);

		if ($query->num_rows() > 0) {
			return $query->result();
		} else {
			return [];
		}
	}
}

Anon7 - 2021