Login   Register  
PHP Classes
elePHPant
Icontem

File: claseaccesobd.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of markitos  >  filecounter  >  claseaccesobd.php  >  Download  
File: claseaccesobd.php
Role: ???
Content type: text/plain
Description: mysql access class
Class: filecounter
File counter class
Author: By
Last change:
Date: 2002-06-27 08:09
Size: 2,086 bytes
 

Contents

Class file image Download
<?
class accesobd
{
var $Hostname;
var $DataBase;
var $Usuario;
var $Password;

Function accesobd ($DataBaseDB=0,$UsuarioDB=0,$PasswordDB=0,$HostnameDB='localhost')
{
  if ((!$DataBaseDB) && (!$UsuarioDB) && (!$PasswordDB))
    { global $DataBaseDB,$UsuarioDB,$PasswordDB,$HostnameDB; }  
		
	$this->DataBase = $DataBaseDB;
	$this->Usuario  = $UsuarioDB;
	$this->Password = $PasswordDB;
	if (!$HostnameDB){ $HostnameDB="localhost"; }
	$this->Hostname = $HostnameDB;
	
	return $this;
}

function InsertaBD ($Sql)
{	
	$Retorno=0;	
  $Link = $this->Conecta();
		$Query = mysql_query($Sql, $Link);		
		$Retorno=mysql_insert_id();
	$this->Desconecta ($Link);
	Return $Retorno;
}

function QueryBDObjeto ($Sql)
{
	$Retorno=array();
	$Link = $this->Conecta();
		$Query = mysql_query($Sql, $Link);		
		if ($Query){ $Retorno = mysql_fetch_object($Query); }
	$this->Desconecta ($Link);
	return $Retorno;
}

function QueryBDArray ($Sql)
{	
	$Retorno = array();
	$Link = $this->Conecta();
		$Query = mysql_query ($Sql, $Link);				
		while ($Resultado = mysql_fetch_array($Query)){
			array_push($Retorno,$Resultado);}    
	$this->Desconecta ($Link);
	return $Retorno;
}

function QueryBDObjetos ($Sql)
{
  $Retorno=array();
	$Link = $this->Conecta();
		$Query = mysql_query($Sql, $Link);		
    while ($Objeto = mysql_fetch_object ($Query))
      {array_push ($Retorno, $Objeto);}  
  $this->Desconecta ($Link);
  return $Retorno;  
}

function ListaCampos ($Tabla)
{
	$Resultado=array();
	$Link = $this->Conecta();
	$fields = mysql_list_fields($this->DataBase, $Tabla, $Link);
	$columns = mysql_num_fields($fields);
	for ($i = 0; $i < $columns; $i++)
		{array_push ($Resultado,mysql_field_name($fields, $i));}
  $this->Desconecta ($Link);
	return $Resultado;	
}

function Conecta()
{
	$Link=mysql_connect($this->Hostname,$this->Usuario,$this->Password);
		mysql_select_db ($this->DataBase,$Link);  
		$Retorno=$Link;
  return $Retorno;  
}

function Desconecta ($Link)
{
  mysql_close($Link);        
}

}
?>