mysql模块部分功能的简单封装
2011-09-30 00:51
603 查看
class mysql { private $db; // datebase connect private $result; // mysql result static private $mysql; // mysql object private function __construct() { // The work before Create an object $this->db = mysql_connect('localhost','root',''); mysql_select_db('hello', $this->db ); } public static function getObject() { //if have a object,return that object,Not create if(! self::$mysql instanceof self) self::$mysql = new self; return self::$mysql; } public function query($sql) { $this->result = mysql_query($sql, $this->db); return $this->result; } public function fetch() { if( isset($this->result ) ) return mysql_fetch_assoc( $this->result ); } public function error() { return 'error:'.mysql_error(); } public function num() // for sql select result { return mysql_num_rows( $this->result ); } public function close() { // return true or false return mysql_close( $this->db ); } }
这样做看起来就只对可移植有用,其它的作用还体会不到
相关文章推荐
- php中mysql模块部分功能的简单封装
- nodejs连接mysql数据库简单封装示例-mysql模块
- nodejs连接mysql数据库简单封装-mysql模块
- MYSQL的简单封装,学习基于托管的C++开发
- 基于php和mysql的简单的dao类实现crud操作功能
- python网页请求urllib2模块简单封装代码
- ffmpeg学习4--ffmpeg类的简单封装,包含解码和定时录像功能
- mysql 5.7.13 在ubuntu上的安装以及部分简单说明
- [原创] 简单测试MySQL 5.1 表分区功能
- ASP常用的几个功能模块封装成函数调用(登录验证,状态切换。。) http://www.tsingfeng.com/archives/?article-89.html
- mybatis+mysql简单的分页功能
- 基于Servlet、JSP、JDBC、MySQL的一个简单的用户注冊模块(附完整源代码)
- MYSQL简单的封装
- MySQL内部模块和功能
- 会员管理模块 - 会员登录功能(简单版本)
- JDBC连接MySQL-基于MVC架构进行简单封装
- Jsp+Jdbc+mysql封装分页功能
- 如何给Python的MySQL模块加功能
- php+MySQL简单的网页分页功能