Changeset 46

Show
Ignore:
Timestamp:
03/26/06 22:07:44 (2 years ago)
Author:
eadiaz
Message:

Introduce get_record_object and get_recordset methods for better performance.
Fix bug related to fetch method, always return an array (empty array when no rows founds).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/public_html/akarru.lib/database.php

    r15 r46  
    3131        function connect() 
    3232        { 
    33                 $this->db=mysql_connect($this->db_host,$this->db_user,$this->db_pass); 
    34                 mysql_select_db($this->db_name,$this->db); 
     33                $this->db= @mysql_connect($this->db_host,$this->db_user,$this->db_pass); 
     34                @mysql_select_db($this->db_name,$this->db); 
    3535                return $this->db; 
    3636        } 
     
    4545        } 
    4646 
     47 
     48        function get_recordset($sql) 
     49        { 
     50                return $this->do_query($sql); 
     51        } 
     52 
     53        function get_record_object($rs) 
     54        { 
     55                return @mysql_fetch_object($rs); 
     56        } 
    4757        // use this for select 
    4858        // rows is the number of rows selected 
     
    5262                $query = $this->do_query($sql); 
    5363                $this->rows = mysql_num_rows($query); 
    54 //             echo "rows = ".$this->rows
     64               $returned = array()
    5565                while($row=@mysql_fetch_object($query)) 
    5666                { 
     
    5969                return $returned; 
    6070        } 
     71 
    6172 
    6273        function fetch_scalar($sql) 
     
    7990        { 
    8091 
    81                 $query = mysql_query($sql) or die("error: ".mysql_error()); 
     92                $query = @mysql_query($sql) or die("error: ".mysql_error()); 
    8293                return $query; 
    8394        } 
     95 
    8496 
    8597        function count_rows($sql)