敢问各位大侠,php连接mysql的时候应该使用静态方法还是非静态方法?解决方法

WBOY
Release: 2016-06-13 13:33:21
Original
826 people have browsed it

敢问各位大侠,php连接mysql的时候应该使用静态方法还是非静态方法?
哪个比较好一些,多谢各位了

------解决方案--------------------
都可以吧。
------解决方案--------------------
应该使用动态方法,理由如下:
1、静态方法只能访问静态属性,会给其他方法带来不便
2、在你的应用中可能会使用到多个数据库连接,使用动态方法时,只需再实例化一个对象
3、在绝大多数应用中,数据库操作并不是单独存在的。一般是与业务逻辑一起封装成类的。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!