<?php
require_once(DIR_FS_ADMIN.DIR_WS_CLASSES.'currency.php');
/**
 * currencies class 
 *
 */
class currencies extends databasetable
{
	/**
	 * initiates the currencies class
	 *
	 */
	function currencies(){
		$this->set_tablename(TABLE_CURRENCIES);
		$this->set_index('currencies_id');
	}
	
	/**
	 * return a currency object
	 *
	 * @param integer $id
	 * @return object
	 */
	function get_currency($id){
		$values = $this->get_row_by_index($id);
		$currency_instance = new currency( (object) current($values) );
		return $currency_instance;
	}

	function get_currencies_id($currency_code){
		$query_raw = sprintf("SELECT %s FROM %s WHERE code='%s'",$this->get_index(),$this->get_tablename(),$currency_code);
		$query = $this->query($query_raw);
		$record = current($query);
		return $record[$this->get_index()];
	}
}
