今天在 apache 2.2 + PHP5.1.1 + MySQL 5.0.1 的环境上编译了PHP支持 mysqli() 的MySQL的功能,的确不错,链接速度提高了很多;想使用mysqli()需要在 PHP编译配置时加上到 MySQL 的 mysql_config 可执行文件的路径,比如我的就是
1
| #./configure <em><strong>--with-mysqli=/opt/MySQL5/bin/mysql_config</strong></em> --enable-xslt --with-xslt-sablot --with-apxs=/opt/apache/bin/apxs --with-gd --with-zlib --with-pgsql=/opt/pgsql |
mysqli() 同时提供 面向对象 与 面向过程 的两种链接方式
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", $mysqli->host_info);
/* close connection */
$mysqli->close();
?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", mysqli_get_host_info($link));
/* close connection */
mysqli_close($link);
?> |
Random Posts
- October 21, 2005 -- 三星幕后操控价格被罚3亿 全美掀反三星情绪
- March 20, 2006 -- 使用TC简单实现控制自己机器的网络速度
- May 12, 2006 -- Windows常用密码破解法[转贴]
- November 14, 2005 -- 使用orkut的双重google帐户
- December 3, 2005 -- Free PDF magazine for you
- September 18, 2009 -- 再听“一起吃苦的幸福”
- April 11, 2006 -- Python for symbian 安装指南
- March 31, 2007 -- Dog and Flower
- October 20, 2005 -- Review: Ubuntu 5.10 Breezy Badger
- April 23, 2006 -- 痛彻心扉
0 Responses to “从PHP获得更快、更安全的Msyql链接?”