PHP Classes
Icontem

File: GafDb.inc.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Douglas M Santos  >  GafDb  >  GafDb.inc.php  
File: GafDb.inc.php
Role: Class source
Content type: text/plain
Description: Main class
Class: GafDb
Simple MySQL database access wrapper
 

Contents

Class file image Download
<?
class mydb{
    var 
$debug=0;
    var 
$host="teste.com.br";
    var 
$user="username";
    var 
$pass="passwrod";
    var 
$database="tablename";
    var 
$error;
    var 
$msgerror;
    var 
$ConId=NULL;
    var 
$recordcount=-1;
    
    var 
$MESSAGE["CONNECTIG"] = "Conectando...";
    var 
$MESSAGE["CONNECTED"] = "Conectado.";    
    var 
$MESSAGE["CONECTIONERROR"] = "Erro ao estabelecer a conexão com o Servidor";
    var 
$MESSAGE["DATABASEERROR"] = "Erro ao selecionar o database";
    var 
$MESSAGE["COMMANDERROR"] = "Erro no comando : ";            
    var 
$MESSAGE["QUERYERROR"] = "Erro na consulta : ";
                    

    function 
GafDb$host $user $pass $database ){
    
$this->host $host;
    
$this->user $user;
    
$this->pass $pass;
    
$this->database $database;
                
    if (
$this->debug<>0) echo $MESSAGE["CONNECTIG"];  // debug
        
$con=mysql_connect($this->host ,$this->user ,$this->pass );
        if(!
$con){ 
            
$this->error mysql_error();
            
$this->msgerror $MESSAGE["CONECTIONERROR"] ;                
            if (
$this->debug<>0mysql_error();  // debug
        

        else{
            
$database mysql_select_db($this->database,$con);
            if(!
$database){ 
                
$this->error mysql_error();
                
$this->msgerror $MESSAGE["DATABASEERROR"] ;                                
                if (
$this->debug<>0mysql_error();// debug            
            
}
            else{
                
$this->ConId $con;        
            }
        }    
     if (
$this->debug<>0) echo $MESSAGE["CONNECTED"] ;  // debug
    
if ($this->error>0) echo $this->msgerror
    } 
// final da função connect



   # executa uma consulta a base de dados MySQL ################################################ Revisão 26/08/2002 #
   
function select$sql ) {
   
        if (
preg_match("/delete/i"$sql)) { Exit; } 
        if (
preg_match("/update/i"$sql)) { Exit; } 
        if (
preg_match("/insert/i"$sql)) { Exit; } 
        
        
               
            
$res = @mysql_query($sql$this->ConId );
            if(!
$res){
                echo  
$MESSAGE["QUERYERROR"] . mysql_error();
                
$this->msgerror mysql_error();
            }
            else{
                
$this->recordcount mysql_num_rows($res);
                return 
$res;
            }

   }

        
    
    
    
       
# executa um comando em uma base de dadosMySQL ################################################ Revisão 26/08/2002 #
   
function Execute$sql ) {
            
$res = @mysql_query($sql$this->ConId );
            if(!
$res){
                echo 
$MESSAGE["COMMANDERROR"] . mysql_error();
                
$this->msgerror mysql_error();
            }
            else{
                
$this->recordcount 0;
                return 
$res;
            }

   }

    
    


}
// final da classe


?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products