<?php
/**************************************************************************/
/* Module Gbook MX v2.0 Copyright (c) 2004 by Víctor Simental             */
/* $Revision 30/01/2004 - $Id class.sql.php - v4.0.1    EPX $             */ 
/* @URI: http://www.phpwebmasters.com                                     */ 
/* ============================================                           */
/* Based in Gbook MX v4.1.0 Copyright (c) 2003 by                         */
/* Víctor Simental - http://gbookmx.sourceforge.net                       */
/* ============================================                           */
/* GbookMX is Based in the Gbook v1.0 for PHP Nuke Copyright (c) 2003 by  */
/* http://www.PHP-Mania.com.ar                                            */
/* Programed and Design By Víctor Simental and German Cúevas              */
/* vicmx@phpwebmasters.com                                                */
/*                                                                        */
/* This program is free software. You can redistribute it and/or modify   */
/* it under the terms of the GNU General Public License as published by   */
/* the Free Software Foundation; either version 2 of the License.         */
/**************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {   
 die ("You can't access this file directly...");
}

class database{

	var $dbconnect;
	var $result_set;
	var $row = array();
	var $rowset = array();
	var $tot_queries = 0;

	// Constructor
	
	function database($host, $dbuname, $dbpassword, $database, $persistency = true){

		$this->persistency = $persistency;
		$this->user = $dbuname;
		$this->password = $dbpassword;
		$this->server = $host;
		$this->dbname = $database;

		if($this->persistency){
			$this->dbconnect = @mysql_pconnect($this->server, $this->user, $this->password);
		}
		else
		{
			$this->dbconnect = @mysql_connect($this->server, $this->user, $this->password);
		}
		if($this->dbconnect){
			if($database != ""){
				$this->dbname = $database;
				$dbselect = @mysql_select_db($this->dbname);
				if(!$dbselect){
					@mysql_close($this->dbconnect);
					$this->dbconnect = $dbselect;
				}
			}
			return $this->dbconnect;
		}
		else
		{
			return false;
		}
	}

	//
	// Other base methods
	//
	function sql_close(){
		if($this->dbconnect){
			if($this->result_set){
				@mysql_free_result($this->result_set);
			}
			$result = @mysql_close($this->dbconnect);
			return $result;
		}
		else
		{
			return false;
		}
	}

	//
	// Base query method
	//
	function sql_query($query = "", $transaction = FALSE){
	            unset($this->result_set);
			$this->result_set = @mysql_query($query, $this->dbconnect);
			return $this->result_set;
	}


	function sql_num_rows($query){
	
			$result = @mysql_num_rows($query);
			return $result;
	}
	

	function sql_fetch_array($query){
	
			$result = @mysql_fetch_array($query);
			return $result;	
	}
	
	function sql_fetch_row($query){	
		
	                $result = @mysql_fetch_row($query);
	                return $result;	
	}
	
	function sql_data_seek($query, $rownum){
		
			$result = @mysql_data_seek($query, $rownum);
			return $result;
	}
	
	function sql_free_result($query){
		
			@mysql_free_result($query);
			return true;
	}

	function sql_fetch_assoc($query){
	
			$result = @mysql_fetch_assoc($query);
			return $result;	
	}
	
	
}//Fin de la Clase 

?>