Ticket #7: db-mysqli.php.diff

File db-mysqli.php.diff, 2.9 KB (added by ishhara, 7 years ago)

suggested changes "diff -ub db.php.org db-mysqli.php"

  • (a) db.php.orig vs. (b) db-mysqli.php

    a b  
    2525        //      DB Constructor - connects to the server and selects a database 
    2626 
    2727        function bbdb($dbuser, $dbpassword, $dbname, $dbhost) { 
    28                 $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); 
     28                $this->dbh = @mysqli_connect($dbhost, $dbuser, $dbpassword); 
    2929                if (!$this->dbh) { 
    3030                        $this->bail(" 
    3131<h1>Error establishing a database connection</h1> 
     
    4545        //      Select a DB (if another one needs to be selected) 
    4646 
    4747        function select($db) { 
    48                 if (!@mysql_select_db($db, $this->dbh)) { 
     48                if (!@mysqli_select_db($this->dbh, $db)) { 
    4949                        $this->bail(" 
    5050<h1>Can&#8217;t select database</h1> 
    5151<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>$db</code> database.</p> 
     
    6969 
    7070        function print_error($str = '') { 
    7171                global $EZSQL_ERROR; 
    72                 if (!$str) $str = mysql_error(); 
     72                if (!$str) $str = mysqli_error($this->dbh); 
    7373                $EZSQL_ERROR[] =  
    7474                array ('query' => $this->last_query, 'error_str' => $str); 
    7575 
     
    119119                // Keep track of the last query for debug.. 
    120120                $this->last_query = $query; 
    121121 
    122                 // Perform the query via std mysql_query function.. 
     122                // Perform the query via std mysqli_query function.. 
    123123                if (SAVEQUERIES) 
    124124                        $this->timer_start(); 
    125125                 
    126                 $this->result = @mysql_query($query, $this->dbh); 
     126                $this->result = @mysqli_query($this->dbh, $query); 
    127127                ++$this->num_queries; 
    128128 
    129129                if (SAVEQUERIES) 
    130130                        $this->queries[] = array( $query, $this->bb_timer_stop() ); 
    131131 
    132132                // If there is an error then take note of it.. 
    133                 if ( mysql_error() ) { 
     133                if ( mysqli_error($this->dbh) ) { 
    134134                        $this->print_error(); 
    135135                        return false; 
    136136                } 
    137137 
    138138                if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) { 
    139                         $this->rows_affected = mysql_affected_rows(); 
     139                        $this->rows_affected = mysqli_affected_rows($this->dbh); 
    140140                        // Take note of the insert_id 
    141141                        if ( preg_match("/^\\s*(insert|replace) /i",$query) ) { 
    142                                 $this->insert_id = mysql_insert_id($this->dbh);  
     142                                $this->insert_id = mysqli_insert_id($this->dbh); 
    143143                        } 
    144144                        // Return number of rows affected 
    145145                        $return_val = $this->rows_affected; 
    146146                } else { 
    147147                        $i = 0; 
    148                         while ($i < @mysql_num_fields($this->result)) { 
    149                                 $this->col_info[$i] = @mysql_fetch_field($this->result); 
     148                        while ($i < @mysqli_num_fields($this->result)) { 
     149                                $this->col_info[$i] = @mysqli_fetch_field($this->result); 
    150150                                $i++; 
    151151                        } 
    152152                        $num_rows = 0; 
    153                         while ( $row = @mysql_fetch_object($this->result) ) { 
     153                        while ( $row = @mysqli_fetch_object($this->result) ) { 
    154154                                $this->last_result[$num_rows] = $row; 
    155155                                $num_rows++; 
    156156                        } 
    157157 
    158                         @mysql_free_result($this->result); 
     158                        @mysqli_free_result($this->result); 
    159159 
    160160                        // Log number of rows the query returned 
    161161                        $this->num_rows = $num_rows;