mysqli - 我真的需要做 $result->close();&$mysqli->close();? [英] mysqli - Do I really need to do $result->close(); & $mysqli->close();?

查看:18
本文介绍了mysqli - 我真的需要做 $result->close();&$mysqli->close();?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始使用mysqli.如果我在小型网站上使用小型数据集(流量方面),我真的需要一直使用这些吗?

Just started using mysqli. If I'm working with small data sets on small websites (traffic-wise), do I really need to use these all the time?

$result->close(); 
$mysqli->close();

另外,对于在没有框架的情况下进行自定义 PHP 和 MySQL 工作的人来说,mysqli 是与 MySQL 交互的一般首选方式吗?

Also, for someone doing custom PHP and MySQL work without a framework, is mysqli the general preferred way of interacting with MySQL?

推荐答案

PHP 将在脚本结束时关闭所有打开的文件和数据库连接.完成连接后手动执行此操作是一种很好的做法,但如果不这样做也无济于事.如果您有一个将在整个脚本中使用的数据库连接,您也可以将其保持打开状态.

PHP will close all open files and DB connections at the end of the script. It's good practice to do it manually when you are done with the connections, but it's no disaster if you don't. If you have a DB connection that will be used throughout the whole script you can as well leave it open.

+1 对 PDO

这篇关于mysqli - 我真的需要做 $result->close();&$mysqli->close();?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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