<?php
/*
* @package		MijoShop
* @copyright	2009-2013 Mijosoft LLC, mijosoft.com
* @license		GNU/GPL http://www.gnu.org/copyleft/gpl.html
* @license		GNU/GPL based on AceShop www.joomace.net
*/

// No Permission
defined('_JEXEC') or die('Restricted access');

class DB {
	private $driver;
	
	public function __construct($driver, $hostname, $username, $password, $database) {
		$this->driver = MijoShop::get('db')->getDbo();
	}
		
  	public function query($sql) {
        $this->driver->setQuery($sql);
        $data =  $this->driver->loadAssocList();

        $query = new stdClass();
        $query->row = isset($data[0]) ? $data[0] : array();
        $query->rows = $data;
        $query->num_rows = count($data);

        return $query;
  	}
	
	public function run($sql) {
        $this->driver->setQuery($sql);
        $data =  $this->driver->execute();

        return $data;
  	}
	
	public function escape($value) {
		return $this->driver->escape($value);
	}
	
  	public function countAffected() {
		return $this->driver->getAffectedRows();
  	}

  	public function getLastId() {
		return $this->driver->insertid();
  	}	
}
?>