<?php class mysql { public function __construct($db_host, $db_user, $db_pwd, $db_database, $conn, $coding) { $this->db_host = $db_host; $this->db_user = $db_user; $this->db_pwd = $db_pwd; $this->db_database = $db_database; $this->conn = $conn; $this->coding = $coding; $this->connect(); } /*数据库连接*/ public function connect() { if ($this->conn == "pconn") { //永久链接 $this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd); } else { //即使链接 $this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd); } if (!mysql_select_db($this->db_database, $this->conn)) { if ($this->show_error) { $this->show_error("数据库不可用:", $this->db_database); } }
private $db_host; //数据库主机
private $db_user; //数据库用户名
private $db_pwd; //数据库用户名密码
private $db_database; //数据库名
private $conn; //数据库连接标识;
private $result; //执行query命令的结果资源标识
private $sql; //sql执行语句
private $row; //返回的条目数
private $coding; //数据库编码,gbk,utf8,gb2312
private $bulletin = true; //是否开启错误记录
private $show_error = false; //测试阶段,显示所有错误,具有安全隐患,默认关闭
private $is_error = false; //发现错误是否立即终止,默认true,建议不启用,因为当有问题时用户什么也看不到是很苦恼的
本站所有资源均由网友贡献或各大下载网站转载。请自行检查软件的完整性!本站所有资源仅供学习参考。请不要将它们用于商业目的。否则,一切后果由您负责!如有侵权,请联系我们删除。联系方式:admin@php.cn
相关文章

12Sep2018
PHP连接Mysql数据库的方法:1、使用mysqli连接mysql数据库,代码如“new mysqli($host,$user,$password,$dbName);”;2、使用PDO连接数据库,代码如“new PDO(...)”。

24Oct2024
PHP 通常与 MySQL(最广泛使用的开源关系数据库管理系统之一)配合使用,以快速高效地处理小型和大型项目中的数据。 无论您是创建一个简单的网站还是广告网站

07Dec2024
MySQL 相当于 Oracle 数据库链接 Oracle 的数据库链接功能可以实现跨多个物理数据库的查询。然而,MySQL...

18Dec2024
从 PHP 中的其他类访问 MySQLi 连接从 PHP 5.6 升级到 7.0 时,必须从 MySQL 过渡到 MySQLi。这...

06Apr2023
PHP是一种广泛使用的服务器端脚本语言,它可以与各种数据库进行交互和通信。在实际的开发中,经常会遇到需要连接数据库的情况。PHP连接数据库时涉及到很多因素,其中一个重要的因素就是连接时间的设置。本文将简要介绍如何设置PHP连接数据库的时间。一、PHP连接数据库的时间设置在PHP中连接数据库的时间一般由两个变量控制:连接超时时间和查询超时时间。连接超时时间指的是连接数据库的最长等

24Nov2024
使用 Mysqli 扩展解决 PHP 中 MySQL 数据库的连接问题使用 mysqli 扩展连接到 MySQL 数据库可以...


Hot Tools
