mysqlidll是PHP对mysql新特性的一个扩展支持在PHP中可以在phpini中加载如下图
interface ingenious incompatible or incomplete(改扩展仍在开发中因为MYSQL和MYSQL都没有正式推出尚在开发中新的特性没有完全实现)
mysqli想实现的目标具体有
更简单的维护
更好的兼容性
向后兼容
mysql(指PHP中的模块)发展到现在显得比较凌乱有必要重新做下整理同时有必要跟上MYSQL(DBMS)的发展步伐加入新的特性的支持以及适应MYSQL(DBMS)以后的版本所以诞生了mysqlidll
mysqlidll的特性
可以和mysqldll一样的方式使用
支持OO接口简简单单调用
支持MYSQL引入的新特性
通过mysqli_init() 等相关函数可以设置高级连接选项
mysqli的使用例子
和以前mysqldll一样的方法
<?php
/* Connect to a MySQL server */
$link = mysqli_connect(
localhost /* The host to connect to */
user /* The user to connect as */
password /* The password to use */
world); /* The default table to query */
if (!$link) {
printf(Cant connect to MySQL Server Errorcode: %sn mysqli_connect_error());
exit;
}
/* Send a query to the server */
if ($result = mysqli_query($link SELECT Name Population FROM City ORDER BY Population DESC LIMIT )) {
print(Very large cities are:n);
/* 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($link);
?>
输出结果
Very large cities are:
Mumbai (Bombay) ()
Seoul ()
São Paulo ()
Shanghai ()
Jakarta ()
使用内置OO接口方式调用
<?php
/* Connect to a MySQL server */
$mysqli = new mysqli(localhost user password world);
if (mysqli_connect_errno()) {
printf(Cant 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 )) {
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();
?>
支持的新特性还有Bound ParametersBound Results等