<?php
/**
 * CSV Improved Database class
 *
 * @package CSVIVirtueMart
 * @subpackage Database
 * @author Roland Dalmulder
 * @link http://www.csvimproved.com
 * @copyright 	Copyright (C) 2006 - 2012 RolandD Cyber Produksi
 * @license 	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * @version $Id: csvidb.php 1892 2012-02-11 11:01:09Z RolandD $
 */
 
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

/**
* @package CSVIVirtueMart
* @subpackage Database
 */
class CsviDb {
	
	private $_database = null;
	
	public function __construct() {
		$this->_database = JFactory::getDBO();
	}
	
	public function setQuery($sql) {
		$this->_database->setQuery($sql);
		$this->cur = $this->_database->query();
	}
	
	public function getRow() {
		if (!is_object($this->cur)) $array = mysql_fetch_object($this->cur);
		else $array = $this->cur->fetch_object();
		if ($array) {
			return $array;
		}
		else {
			if (!is_object($this->cur)) mysql_free_result( $this->cur );
			else $this->cur->free_result();
			return false;
		}
	}
	
	public function getErrorNum() {
		return $this->_database->_errorNum;
	}
	
	public function getErrorMsg() {
		return $this->_database->_errorMsg;
	}
	
	public function getNumRows() {
		return $this->_database->getNumRows($this->cur);
	}
	
	public function getQuery() {
		return $this->_database->getQuery();
	}
}
?>