<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Model_user_license_attachment extends CI_Model {

	public function fetchAttachment($user_id = null, $mask_id = null)
	{
		$this->db->select('a.*');
		if($user_id)$this->db->where('user_id',$user_id);
		if($mask_id)$this->db->where('mask_id',$mask_id);
		$query = $this->db->get('user__license_attachment a');

		return ($query->num_rows() > 0)?$query->result():null;
	}

	public function createAttachment($input = array())
	{
		$this->db->insert('user__license_attachment',$input);
		return $this->db->insert_id();
	}

	public function editAttachment($input,$id = null, $license_id = null)
	{
		if($id) $this->db->where('id',$id);
		if($license_id) $this->db->where('license_id',$license_id);

		$this->db->set($input);
		// $this->db->where('id',$id);
		$this->db->update('user__license_attachment');
	}

}
?>