Viewing File: /people/testlab/www/testlab.com.pl/inc/db.php

<?php
//################################################/
//#                     Klasa obs�ugi bazy danych          #/
//################################################/


// Definiowane sta�e konfiguracyjne
define("HOST","localhost:3306");
define("USER","testlab");
define("PASSWORD","SarrUMjL");
define("DB_NAME","testlab");

class DBConnect
{
        var $connection = NULL;
        var $rows = NULL;
        var $lrs= NULL;
        // parametry konfiguracyjne
                /*
                        db_kind mo�e przyjmowa� warto�ci:
                        0 - MySQL;
                        1 - PostgreSQL;
                        2 - Oracle;
                */

        function DBConnect($param = NULL)
        {
          return $this->connect();
        }

        function connect($connect_string = NULL)
        {
                if($this->connection)
                {
                        @mysql_Close($this->connection);
                        $this->connection= null;
                }
 $this->connection= @mysql_Connect (HOST,USER,PASSWORD) or 
die("<HR><center>".$this->error()."Brak połączenia - Przepraszamy.</center><HR>");
				
				@mysql_query('SET NAMES \'utf8\'');
				@mysql_query('SET character_set_client \'utf8\'');
				@mysql_query('SET character_set_results \'utf8\'');
				@mysql_query('SET character_set_connection \'utf8\'');

                @mysql_Select_DB(DB_NAME);
                return $this->connection;
        }//end function connect



        function query($sql)
       {
                $sql=str_replace("`*`","*",$sql);
                $this->lrs= @mysql_query($sql,$this->connection);
                if(!$this->lrs)
                        return $this->lrs;
                $this->rows[$this->lrs]= 0;
                return $this->lrs;
        }

        function fetchrow($rs= null)
        {
                global $db_kind;
                if(!$rs)
                        $rs= $this->lrs;
                $arr = @mysql_fetch_array($rs,MYSQL_ASSOC);
                $this->rows[$rs]= $this->rows[$rs] + 1;
                $this->lrs= $rs;
                return $arr;
        }

        function fetch_result($rs,$row,$column)
        {
                if (!$rs)
                        $rs = $this-lrs;
                else
                        $this->lrs = $rs;
                return @mysql_result($rs,$row,$column);
        }

        function free_result($rs)
        {
                if (!$rs)
                        $rs = $this-lrs;
                else
                        $this->lrs = $rs;
                return @mysql_free_result($rs);
        }

        function insert_id()
        {
                return @mysql_insert_id();
        }
        
        function numrows($rs= null)
        {
                if(!$rs)
                        $rs= $this->lrs;
                return @mysql_num_rows($rs);
        }

        function numfields($rs= null)
        {
                if(!$rs)
                        $rs= $this->lrs;
                return @mysql_num_fields($rs);
        }

        function error()
        {
                return @mysql_error($this->connection);
        }

        function close()
        {
                $result= @mysql_close($this->connection);
                $this->connection= NULL;
                return $result;
        }
}// end class DBConnection


?>
Back to Directory File Manager