php_mysqli.dll是什么,php_mysqli.dll 的了解

MYSQLI到底是什么呢?

MYSQLI有何优点,MYSQLI如何开启?

在新下载的php5中你会发现多了一个mysqli.dll,它是干什么用的呢?

我简单介绍下。。。

mysqli.dll是php对mysql新特性的一个扩展支持。

mysql是非持继连接函数而mysqli是永远连接函数。

也就是说mysql每次链接都会打开一个连接的进程而mysqli多次运行mysqli将使用同一连接进程,从而减少了服务器的开销,在高MYSQL查询环境下mysqli性能比mysql好点 在php5中可以在php.ini中加载

修改C:/WINDOWS/PHP.INI,把;extension=php_mysqli.dll前面的; 去掉就能使PHP加载MYSQLI功能 mysql后面的 i,

指improved, interface, ingenious, incompatible or incomplete(改扩展仍在开发中,因为mysql4。1和mysql5都没有正式推出尚在开发中,新的特性没有完全实现)

mysqli想实现的目标具体有:

-更简单的维护 -更好的兼容性 -向后兼容 mysql(指php中的模块)发展到现在显得比较凌乱,有必要重新做下整理。同时,有必要跟上mysql(dbms)的发展步伐,加入新的特性的支持,以及适应mysql(dbms)以后的版本。

所以诞生了mysqli.dll mysqli.dll的特性:

-可以和mysql.dll一样的方式使用 -支持oo接口,简简单单调用 -支持mysql4。1引入的新特性 -通过mysqli_init() 等相关函数,可以设置高级连接选项 mysqli的使用例子:

1.和以前mysql.dll一样的方法:

/* connect to a mysql server */

$conn = mysqli_connect(

'localhost', /* the host to connect to */

'user', /*用户名*/

'password', /* 密码*/

'world'); /* 连接的数据库名*/

if (!$conn) {

printf("can't connect to mysql server. errorcode: %sn", mysqli_connect_error());

exit;

}

/* send a query to the server */

if ($result = mysqli_query($conn, 'select name, population from city order by population desc limit 5')) /*从city表中查找 name,populaton列*/

{

print("very large cities are:");

/* fetch the results of the query */

while( $row = mysqli_fetch_assoc($result) )

{

printf("%s (%s)n", $row['name'], $row['population']);

}

/* destroy the result set and free the memory used for it */

mysqli_free_result($result);

}

/* close the connection */

mysqli_close($conn);

?>

输出结果:

very large cities are:shandong 200?shanghai 100?

2.使用内置oo接口方式调用:

/* connect to a mysql server */

$mysqli = new mysqli('localhost', 'user', 'password', 'test');

if (mysqli_connect_errno()) {

printf("can't connect to mysql server. errorcode: %sn", mysqli_connect_error());

exit;

}

/* send a query to the server */

if ($result = $mysqli->query('select name, population from city order by population desc limit 5')) {

print("very large cities are:n");

/* fetch the results of the query */

while( $row = $result->fetch_assoc() ){

printf("%s (%s)n", $row['name'], $row['population']);

}

/* destroy the result set and free the memory used for it */

$result->close();

}

/* close the connection */ $mysqli->close(); ?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值