Monday 27 August 2018

Going from mysql to mysqli

When you switch to PHP 5.5, you are faced with the problem that the MySQL database becomes unavailable. Rather is available, but in a new way. All the good old mysql_ * functions became deprecated and will no longer be available at all. On closer inspection, there is nothing terrible and complicated if you do not go into the jungle of new features of MySql.
So all you need to do to migrate from mysql to mysqli is to replace it contextually throughout the code:
It wasBecame
mysql_connect (HostName, UserName, Password)); mysql_select_db (DBName); mysql_query ("SET NAMES". $ charset); mysql_set_charset ($ charset); $ GLOBALS ['link'] = mysqli_connect (HostName, UserName, Password, DBName); mysqli_set_charset ($ GLOBALS ['link'], $ charset);
mysql_insert_id () mysqli_insert_id ($ GLOBALS ['link'])
mysql_query ( mysqli_query ($ GLOBALS ['link'],
mysql_fetch_assoc mysqli_fetch_assoc
mysql_num_rows mysqli_num_rows
mysql_affected_rows () mysqli_affected_rows ($ GLOBALS ['link'])
Perhaps you are using some other MySql functions in your project, but replacing them with a global search for the string "mysql_" and replacing contextually with similar MySqli functions will not be a big deal and will not take much time.

0 comments:

Post a Comment