Location: PHPKode > scripts > mydb > mydb/mydb.php
<?php
class mydb
{
       #this script was written by iman ebrahimi tajadod
       #hide@address.com
        var $server='localhost';//database server
        var $user='root';//database username
        var $pass='';//database password
        var $db='joomla';//database name
        var $con; //connection handler
        var $q_r;//query result
        var $affected_rows;
        var $result;
        var $arr;
        function mydb()
        {
                $this->con=mysql_connect($this->server,$this->user,$this->pass) or die(mysql_error());
                mysql_select_db($this->db,$this->con);
        }
        function query($sql)  //run query
        {
               $sql=addcslashes($sql,"./\?#!");
               $this->q_r=mysql_query($sql);
               $this->affected_rows=mysql_affected_rows($this->con);
               return $this-q_r;
        }
        function fetch($sql,$mod='assoc')       //fetch record
        {
               $this->query($sql);
               switch($mod)
               {
                    case 'array': $this->result=mysql_fetch_array($this->q_r);break;
                    case 'assoc': $this->result=mysql_fetch_assoc($this->q_r);break;
               }

        }
        function fetch_num($sql,$start=0,$num=5)     //fetch records
        {
               $sql.=" limit ".$start.','.$num;
               $this->query($sql);
               for ($i=0;$i<$this->affected_rows;$i++)
                     $this->arr[$i]=mysql_fetch_assoc($this->q_r);

        }
        function fetch_all($sql)   //fetch all records
        {
                $this->query($sql);
                for ($i=0;$i<$this->affected_rows;$i++)
                     $this->arr[$i]=mysql_fetch_assoc($this->q_r);
        }

}

?>
Return current item: mydb