mysqli二次封装 蛋疼 本来就面向对象 又封装了一次
php代码:
<?php //mysqli的DB 类 /** * */ class MYSQLI{ public $dbhost; //主机 public $dbuser; //用户 public $dbpassword; //密码 public $dbname; //数据库名称 public $dbport; //端口号 public $errno; //错误号 public $error; //错误内容 public $mysqli; //mysqli连接对象句柄 public $query; //query结果 public $result; //查询的结果集 public $aff_rows; //受影响的行数 public $num_rows; //查询结果条数 function __construct(){ //连接数据库 $this->mysqli = new mysqli($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname, $this->dbport); if($this->mysqli->connect_error){ die('Connect Error ('.$this->mysqli->connect_errno.')'.$this->mysqli->connect_error); } } //执行 dml 操作语句 function dml($sql){ $this->query = $this->mysqli->query($sql); } //取得受影响的行数 function affected_rows(){ $this->aff_rows = $this->mysqli->affected_rows; } //执行 dql 语句 function dql($sql){ $this->result = $this->mysqli->query($sql); } //取得查询结果条数 function num_rows(){ $this->num_rows = $this->result->num_rows; } //取得查询结果集 function fetch_object(){ //以对象形式返回 return $obj = $this->result->fetch_object(); } } ?>
Copy after login
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
1 weeks ago
By DDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Where to find the Crane Control Keycard in Atomfall
1 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1359
52

