/ PHP

get_results PHP function not working on CentOS

There are instances where the PHP function - get_results will not work on CentOS (this maybe the case with other Linux based operating systems as well). I faced this issue while deploying a project on CentOS which was originally developed on Windows. All my INSERT, UPDATE and DELETE database statements were working properly, but bulk SELECTstatements had issues. After closer inspection I was able to narrow it down to get_results function.

While reading the documentation, I came across this on the get_results documentation page -

MySQL Native Driver Only
Available only with mysqlnd.

Using this post on StackOverflow I was able to determine if mysqlnd driver was actually installed and as expected it wasn't.

Posting php code from the StackOverflow post -

$mysqlnd=function_exists('mysqli_fetch_all');
if($mysqlnd) {
   echo 'mysqlnd enabled!';
}

Here are the steps used to get the mysqlnd driver working on CentOS,

// First remove the existing MySQL driver<br></br>
yum --enablerepo=remi,remi-test remove php-mysql

// Then go ahead and install mysqlnd<br></br>
yum --enablerepo=remi,remi-test install php-mysqlnd

// Restart httpd<br></br>
/sbin/service httpd restart

// If you have phpMyAdmin, re-install it so that it uses the new MySQL driver
yum remove phpMyAdmin
yum install phpMyAdmin

Once the mysqlnd driver had been installed I had no issues while using the get_results function.