PHP Classes

PHP MySQL upgrade to MySQLi

Recommend this page to a friend!

      PHP MySQL to MySQLi  >  PHP MySQL to MySQLi package blog  >  Do tomorrow what does...  >  All threads  >  PHP MySQL upgrade to MySQLi  >  (Un) Subscribe thread alerts  
Subject:PHP MySQL upgrade to MySQLi
Summary:Too easy... something must be wrong.
Messages:5
Author:Steve K
Date:2017-04-23 23:15:16
 

  1. PHP MySQL upgrade to MySQLi   Reply   Report abuse  
Picture of Steve K Steve K - 2017-04-23 23:15:17
I followed your directions in step one (only). The builder of this site (not me) had anticipated MySQLi and had a 'case tree' that read the database type. Based on that 'type', it used the appropriate class. However, I only changed the database 'type' from mysql to mysqli ... there were no errors on load. The class being used (mysqlie.class.php) only has a handful of functions in it. I did not edit every instance of mysql throughout the site, yet the site seems to be functioning normally. Why would this be?? Thanks for this tutorial.

  2. Re: PHP MySQL upgrade to MySQLi   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-04-23 23:27:13 - In reply to message 1 from Steve K
It sounds like it has database wrappers already set up and the actual calls to the database are being made through the appropriate wrapper.

Without seeing the code I could be wrong, however no changes would need to be made for everything to function properly if this where the case.

Dave

  3. Re: PHP MySQL upgrade to MySQLi   Reply   Report abuse  
Picture of Steve K Steve K - 2017-04-24 16:38:08 - In reply to message 2 from Dave Smith
Is this the wrapper that you refer to, and going forward will I have to edit everything else in the site? There are tons of pages using just MySQL.

/**
* Constructs the class and initializes some variables
* @param string $server_name - The server name for the connection
* @param string $username - The username for the connection
* @param string $password - The password for the connection
* @param string $name - The name of the database
* @param object $qls - Contains all the other classes
* @optional integer $port - Port number if needed
* @return void but will output error if found
*/
function MySQLie($server_name, $username, $password, $name, &$qls, $port = false) {
$this->qls = &$qls;
$this->server_name = $server_name;
$this->username = $username;
$this->password = $password;
$this->name = $name;
$this->port = $port;

// Connect to the database, or if you want die I don't care :P
$this->connection = ($this->port !== false) ? mysqli_connect($this->server_name, $this->username, $this->password, $this->name, $this->port) : mysqli_connect($this->server_name, $this->username, $this->password, $this->name);
if (mysqli_connect_errno()) {
die(mysqli_connect_error());
}
}

  4. Re: PHP MySQL upgrade to MySQLi   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2017-04-24 17:29:16 - In reply to message 3 from Steve K
That is part of a class, which looks like a database wrapper, that is making a mysqli connection. As long as the code calls this class, it should handle everything as mysqli.

Dave

  5. Re: PHP MySQL upgrade to MySQLi   Reply   Report abuse  
Picture of Rajeev Kumar Lamba Rajeev Kumar Lamba - 2017-06-13 12:46:28 - In reply to message 4 from Dave Smith
can you help me to integrate this package in my web file called mysql.php, I am using interspire shopping cart that is giving me error on php 7 like this :-

Your PHP installation does not have MySQL support. Please enable MySQL support in PHP or ask your web host to do so for you.

I dont know much about php and codes so not able to do so

Thanks