<?php
/*
+--------------------------------------------------------------------------
|   TanyaCMS - Question and Answer Sofware
|   -----------------------------------------------------------------------
|   by fbschool dev team
|   (c) 2011 - 2012 FBSCHOOL
|   http://www.fbschool.com/tanyacms
|   -----------------------------------------------------------------------
|   This is NOT a freeware, use is subject to license terms
|   Support: 13455n@gmail.com
+--------------------------------------------------------------------------
*/


if (!defined('IN_TANYACMS'))
{
	die;
}

class education_class extends ASK_MODEL
{

	/**
	 * Add School Information
	 * 
	 * @param int $user_id User ID
	 * @param str $school_name_tmp University(Only with)
	 * @param int $years		Years
	 * @param str hostel	Hostel
	 * 
	 */
	
	function add_education_experience($uid, $school_name, $years, $departments = '')
	{
		$insert_arr['uid'] = intval($uid);
		$insert_arr['school_name'] = htmlspecialchars($school_name);
		$insert_arr['education_years'] = intval($years);
		$insert_arr['departments'] = htmlspecialchars($departments);
		$insert_arr['add_time'] = time();
		
		//Insert obtain the user ID
		return $this->insert('education_experience', $insert_arr);
	}

	/**
	  * By user ID access to Education
	  * 
	  * @param $uid
	  * 
	  * @return array
	  */
	function get_education_experience_list($uid)
	{
		$uid = intval($uid);
		
		if (! $uid)
		{
			return false;
		}
		
		return $this->fetch_all('education_experience', 'uid = ' . intval($uid), 'education_years DESC');
	
	}

	/**
	  * By user ID access to Education
	  * 
	  * @param $uid
	  * 
	  * @return array
	  */
	function get_education_experience_row($education_id, $uid)
	{
		$uid = intval($uid);
		$education_id = intval($education_id);
		
		if (! $uid)
		{
			return false;
		}
		
		return $this->fetch_row('education_experience', "education_id = {$education_id} AND uid = {$uid}");
	}

	/**
	 * Updating school experience
	 * 
	 * @param  $update_arr
	 * @param  $education_id
	 * @param  $uid
	 */
	function update_education_experience($update_arr, $education_id, $uid)
	{
		$uid = intval($uid);
		$education_id = intval($education_id);
		
		if ((! $uid) || (! $education_id))
		{
			return false;
		}
		
		return $this->update('education_experience', $update_arr, "uid = {$uid} AND education_id = {$education_id}");
	
	}

	/**
	  * Delete school experience
	  * 
	  * @param  $education_id
	  * @param  $uid
	  */
	function del_education_experience($education_id, $uid)
	{
		return $this->delete('education_experience', "uid = " . intval($uid) . " AND education_id = " . intval($education_id));
	}
}