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

查看:89
本文介绍了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天全站免登陆