更多>
最新下载
24小时阅读排行榜
- 1 css 想让背景渐变色随窗口宽度变化怎么办_linear-gradient 与 media query
- 2 c# 乐观锁和悲观锁在c#中的实现
- 3 Go 中切片的容量机制:为什么 append 能突破初始 cap 限制?
- 4 c# System.IO.Pipelines 和 NetworkStream 的性能对比
- 5 GraphQL查询结果如何映射到XML
- 6 css 想让输入框在 focus 时高亮怎么办_使用 css tailwind focus 工具类
- 7 c++高频交易(HFT)系统开发有哪些性能优化要点? (低延迟编程)
- 8 如何在 Nuxt 2 中正确使用 emit 实现父子组件通信
- 9 WCF服务中的XML序列化怎么配置 DataContractSerializer
- 10 如何让 Flex 布局中左侧 div 随右侧内容自动等高填充背景色
- 11 css flexbox 布局实现响应式设计_自动排列页面元素
- 12 mysql表继承怎么做_mysql面向对象设计方案解析
- 13 如何将 HTML 输入字段转换为可交互的段落元素并实现焦点切换
- 14 如何在 Pandas DataFrame 开头补全缺失时间戳并统一插值降频
- 15 Laravel中如何定义模型范围Scopes_Laravel本地作用域Scope使用方法【详解】
更多>
最新教程
-
- Node.js 教程
- 15532 2025-08-28
-
- CSS3 教程
- 1544718 2025-08-27
-
- Rust 教程
- 22811 2025-08-27
-
- Vue 教程
- 25287 2025-08-22
-
- PostgreSQL 教程
- 21861 2025-08-21
-
- Git 教程
- 8876 2025-08-21
下载首页 / 类库下载 / 其它类库
<?php
defined('ACC')||exit('Access Denied');
// 封装mysql操作类,包括连接功能,及查询功能.
class mysql extends absdb{
protected static $ins = null;
protected $host; // 主机名
protected $user; // 用户名
protected $passwd; // 密码
protected $db; // 数据库名
protected $port; // 端口
protected $conn = null;
// 在内部操作,获得一个对象
public static function getIns() {
if(self::$ins === null) {
self::$ins = new self();
}
$conf = conf::getIns();
self::$ins->host = $conf->host;
self::$ins->user = $conf->user;
self::$ins->passwd = $conf->pwd;
self::$ins->db = $conf->db;
self::$ins->port = $conf->port;
self::$ins->connect();
self::$ins->select_db();
self::$ins->setChar();
return self::$ins;
}
// 不让外部做new操作,
protected function __construct() {
}
// 连接数据库
public function connect() {
$this->conn = @mysql_connect($this->host,$this->user,$this->passwd,$this->port);
if(!$this->conn) {
$error = new Exception('数据库连不上',9);
throw $error;
}
}
// 发送sql查询
public function query($sql) {
$rs = mysql_query($sql,$this->conn);
if(!$rs) {
log::write($sql);
}
return $rs;
}这是一个单例模式实现mysql的PHP类,需要的朋友可以下载使用。
本站所有资源都是由网友投搞发布,或转载各大下载站,请自行检测软件的完整性!本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!如有侵权请联系我们删除下架,联系方式:admin@php.cn
