Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instal mysqlnd in a hosted website

I am developing a web-site in PHP - MySQL. Here are some points to note:

  • I am using MySQLi API for database access.
  • In my local installation of XAMPP (a Windows 7 machine), the PHP version is 5.3.8, MySQL version is mysqlnd 5.0.8-dev - 20102224
  • I have hosted the web-site on a free hosting server for testing "cuccfree.com". Here the PHP version is 5.3.14 and the MySQL version is 5.1.66. It still has a lot better support for MySQLi compared to many other hosting companies.
  • On phpinfo'ing the both, the local machine shows mysqlnd driver installed, but the hosting server has not.
  • I have created a wrapper class for MySQLi which fetches the ResultSet using the function mysqli_stmt::get_result(). This function works on my local machine but not on the cuccfree.com hosting server, because the mysqli object does does not have a method named get_result(). Though, the mysqli_stmt object is prepared and bind_param'ed successfully.
  • The manual page for mysqli_stmt on php.net says that for using mysqli_stmt::get_result(), we need to have mysqlnd driver installed.
  • The server's configuration offers the use of mysqli_stmt::bind_object(). But get_result() seems to be a much better choice for me, since we can have result in the form of an array. I have overridden the function to accept variable number of arguments using the following line:

    call_user_func_array(array($stmt, 'bind_param'), $params);

where the $params is an array of parameters.

  • Using bind_object(), I have to bind every column returned to a variable. In that case, I cannot create a wrapper class function to handle all SQL queries at a single point.

I looked for several hosting companies, talked and mailed to customer support of many companies, including GoDaddy and Manas Hosting, they do not offer the use of mysqlnd. They, very logically, insist the use of VPS or Dedicated Servers. And obviously, both the suggested options are very costly, even at the entry level.

So, finally to my question, can we installed / embed mysqlnd into a website on a Linux server? If not, what alternative do I have to prevent me from changing the code of entire website, which will take me many-many days?

Regards

like image 483
Kumar Kush Avatar asked Oct 22 '22 23:10

Kumar Kush


2 Answers

I experienced this before as well and it was a real time-eater. The only solution is to use PDO if you do not want to upgrade to VPS. You can try to SSH in the shared hosting account but good luck trying to change anything because the web administrators are smart in web hosting. The web hosters I have even went as far as to remove yum.conf from /etc/ and denied permission to it to where you couldn't install any packages through yum. If you get a VPS however and you have cpanel, you can change the configuration options for PHP. It took me a long time to figure this out, but I learned that you can change PHP options in CPanel by running /usr/local/cpanel/scripts/easyapache. If you run Apache 2.2, you can also change the config options for PHP config options by following this documentation. Without a VPS, there's no way to change CPanel like that I'm pretty sure. I hope this post helps somewhat.

like image 190
John61590 Avatar answered Oct 27 '22 16:10

John61590


Unless your hosting company has enabled the use of dl() which I can almost guarantee they have not, then no.

Your second option which you've already pointed out, would be to write (or find, they may exist, maybe someone else can point you in that direction) a compatibility layer for mysqlnd. I'm assuming there isn't one already existing since you wrote your own. So unfortuantely, I believe you are stuck in the mud.

In any event, you should really use PDO next time :) But I know, hindsight is 20/20, so...

like image 33
A.B. Carroll Avatar answered Oct 27 '22 16:10

A.B. Carroll