mysql 5.1支持mysqli_简单介绍下 PHP5 中引入的 MYSQLI的用途_php基础_脚

这段代码展示了如何使用PHP5中的MySQLi扩展连接到MySQL服务器并执行查询。它显示了如何获取最大城市,并强调了MySQLi的新特性,如Bound Parameters和Bound Results。通过了解这些变化,开发者可以更好地掌握PHP数据库操作的最新趋势。
摘要由CSDN通过智能技术生成

/* Connect to a MySQL server */

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

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

?>

支持的新特性还有:Bound Parameters,Bound Results等。。。

有兴趣的可以直接去参看原英文:

http://www.zend.com/php5/articles/php5-mysqli.php#fn3

注:感觉这个不是对所有人都有用。不过。。。相信可以帮助大家多了解些“变化”,能更好的把握“趋势” 8-)

这就是微学网-程序员之家为你提供的"简单介绍下 PHP5 中引入的 MYSQLI的用途_php基础_脚"希望对你有所帮助.本文来自网络,转载请注明出处:http://www.weixuecn.cn/article/707.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值