Ticket #7: db-mysqli.php.diff
| File db-mysqli.php.diff, 2.9 KB (added by ishhara, 7 years ago) |
|---|
-
(a) db.php.orig vs. (b) db-mysqli.php
a b 25 25 // DB Constructor - connects to the server and selects a database 26 26 27 27 function bbdb($dbuser, $dbpassword, $dbname, $dbhost) { 28 $this->dbh = @mysql _connect($dbhost, $dbuser, $dbpassword);28 $this->dbh = @mysqli_connect($dbhost, $dbuser, $dbpassword); 29 29 if (!$this->dbh) { 30 30 $this->bail(" 31 31 <h1>Error establishing a database connection</h1> … … 45 45 // Select a DB (if another one needs to be selected) 46 46 47 47 function select($db) { 48 if (!@mysql _select_db($db, $this->dbh)) {48 if (!@mysqli_select_db($this->dbh, $db)) { 49 49 $this->bail(" 50 50 <h1>Can’t select database</h1> 51 51 <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> … … 69 69 70 70 function print_error($str = '') { 71 71 global $EZSQL_ERROR; 72 if (!$str) $str = mysql _error();72 if (!$str) $str = mysqli_error($this->dbh); 73 73 $EZSQL_ERROR[] = 74 74 array ('query' => $this->last_query, 'error_str' => $str); 75 75 … … 119 119 // Keep track of the last query for debug.. 120 120 $this->last_query = $query; 121 121 122 // Perform the query via std mysql _query function..122 // Perform the query via std mysqli_query function.. 123 123 if (SAVEQUERIES) 124 124 $this->timer_start(); 125 125 126 $this->result = @mysql _query($query, $this->dbh);126 $this->result = @mysqli_query($this->dbh, $query); 127 127 ++$this->num_queries; 128 128 129 129 if (SAVEQUERIES) 130 130 $this->queries[] = array( $query, $this->bb_timer_stop() ); 131 131 132 132 // If there is an error then take note of it.. 133 if ( mysql _error() ) {133 if ( mysqli_error($this->dbh) ) { 134 134 $this->print_error(); 135 135 return false; 136 136 } 137 137 138 138 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); 140 140 // Take note of the insert_id 141 141 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); 143 143 } 144 144 // Return number of rows affected 145 145 $return_val = $this->rows_affected; 146 146 } else { 147 147 $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); 150 150 $i++; 151 151 } 152 152 $num_rows = 0; 153 while ( $row = @mysql _fetch_object($this->result) ) {153 while ( $row = @mysqli_fetch_object($this->result) ) { 154 154 $this->last_result[$num_rows] = $row; 155 155 $num_rows++; 156 156 } 157 157 158 @mysql _free_result($this->result);158 @mysqli_free_result($this->result); 159 159 160 160 // Log number of rows the query returned 161 161 $this->num_rows = $num_rows;