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

class Servicepackage_model extends MY_Model
{
	
	protected $table_name = 'tblservicepackage';
	protected $id_name = 'p_id';
	const TOKENPW = 'violet';
	
	function __construct()
	{
        parent::__construct();
		$this->vservices->setApiUrl($this->config->item('api_url'));
		$this->vservices->setConnection($this->curl);
    } 
	
    function getAllPackages()
    {
    	$this->db->query('UNLOCK TABLES');
        $sql="SELECT * FROM ".$this->table_name."";
        return $this->db->query($sql)->result_array();
    }
    
    function getPackage($p_id)
    {
    	$this->db->query('UNLOCK TABLES');
        $sql="SELECT * FROM ".$this->table_name." WHERE ".$this->id_name."=".$p_id;
        return $this->db->query($sql)->row_array();
    }
    
    function getPackagePriceByCode ($p_code) 
    {
    	$this->db->query('UNLOCK TABLES');
    	$sql='SELECT p_price FROM '. $this->table_name .' WHERE p_code = ?';
    	$query =  $this->db->query($sql , array($p_code));
    	$row = $query->row_array();
    	return $row['p_price'];
    }
    
    function getPackageByCode ($p_code)
    {
    	$this->db->query('UNLOCK TABLES');
    	$sql='SELECT * FROM '. $this->table_name .' WHERE p_code = ?';
    	$query =  $this->db->query($sql , array($p_code));
    	$row = $query->row_array();
    	return $row;
    }
	
}
