通过页面打开mysql连接完全鲁re吗? [英] Is it totally reckless to leave mysql connection open through a page?

查看:108
本文介绍了通过页面打开mysql连接完全鲁re吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查询数据库时是否感到极端偏执?每当需要执行新查询时,我都会尽可能地打开和关闭mysql连接.恐怕(尤其是启用了Ajax的页面)这会导致性能大幅下降.

When querying the db is it plausible to feel extremely paranoid? I go as far as opening and closing mysql connection every time a new query has to be done. I am afraid that (especially with the ajax enabled pages) this would cause great performance downgrading.

我应该继续使用此方法还是至少在每个页面中一次(而不是每个查询)打开和关闭连接? (我正在用php btw编写)

Should I continue in this method or at least open and close connections once in everypage (instead of per-query)? (i'm writing in php btw)

谢谢.

推荐答案

是的,每次连接的开销都会很大.我建议您在完成操作后将其关闭,仅通过打开连接而不对其运行查询就不太可能打开漏洞.

Yes, the overhead of connecting every time will be considerable. I suggest you just close it when you're done, it's very unlikely that simply having an open connection without running queries on it will open you to vulnerabilities.

这篇关于通过页面打开mysql连接完全鲁re吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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