在托管网站中安装mysqlnd [英] Instal mysqlnd in a hosted website

查看:107
本文介绍了在托管网站中安装mysqlnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP开发一个网站-MySQL.这里有一些注意事项:

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

  • 我正在使用 MySQLi API进行数据库访问.
  • 在本地安装的XAMPP(Windows 7计算机)中,PHP版本为 5.3.8 ,MySQL版本为 mysqlnd 5.0.8-dev-20102224
  • 我已经将该网站托管在免费的托管服务器上,用于测试"cuccfree.com".这里的PHP版本是 5.3.14 ,而MySQL版本是 5.1.66 .与许多其他托管公司相比,它对MySQLi的支持要好得多.
  • 在同时使用phpinfo的情况下,本地计算机显示 mysqlnd 驱动程序已安装,但托管服务器尚未安装.
  • 我为MySQLi创建了一个包装器类,该包装器类使用函数 mysqli_stmt :: get_result()获取ResultSet.此功能在我的本地计算机上有效,但在cuccfree.com托管服务器上无效,因为 mysqli 对象没有名为 get_result()的方法.不过, mysqli_stmt 对象已已准备,并且已成功 bind_param'.
  • php上的 mysqli_stmt 手册页.net 说,要使用 mysqli_stmt :: get_result(),我们需要安装 mysqlnd 驱动程序.
  • 服务器的配置允许使用 mysqli_stmt :: bind_object().但是get_result()对我来说似乎是一个更好的选择,因为我们可以数组的形式生成结果.我使用以下行重写了该函数以接受可变数量的参数:

  • 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);

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

其中$ params是参数数组.

where the $params is an array of parameters.

  • 使用bind_object(),我必须将返回的每个列绑定到一个变量.在那种情况下,我无法创建一个包装器类函数来一次性处理所有SQL查询.

我寻找了几家托管公司,与包括GoDaddy和Manas Hosting在内的许多公司的客户支持部门进行了交谈和邮寄,它们不提供 mysqlnd 的使用.从逻辑上讲,他们坚持使用VPS或专用服务器.显然,即使在入门级,两个建议的选择也都非常昂贵.

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.

那么,最后,我的问题是,我们可以将mysqlnd安装/嵌入到Linux服务器上的网站中吗?如果没有,我该如何阻止我更改整个网站的代码,这将花费我很多天?

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?

致谢

推荐答案

我之前也曾经历过,这是一个真正的时间消耗者.唯一的解决方案是如果您不想升级到VPS,则使用PDO.您可以尝试在共享托管帐户中使用SSH进行登录,但由于网络管理员精通Web托管,因此尝试更改任何方法都非常幸运.我什至已经把网络托管服务商从/etc/中删除yum.conf并拒绝了它对您无法通过yum安装任何软件包的许可.但是,如果获得VPS并具有cpanel,则可以更改PHP的配置选项.我花了很长时间才弄清楚这一点,但是我了解到可以通过运行/usr/local/cpanel/scripts/easyapache来更改CPanel中的PHP选项.如果运行Apache 2.2,则还可以通过遵循本文档来更改PHP配置选项的配置选项.没有VPS,就没有办法像我确定的那样更改CPanel.我希望这篇文章能有所帮助.

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.

这篇关于在托管网站中安装mysqlnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆