自己写了个mysqli简单类

非常简单,刚刚有人在讨论mysqli,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
*MYSQLi数据库操作类
*/

class db{

private $host;
private $user;
private $pass;
private $name;
private $link;

function __construct($host,$user,$pass,$name){
$this->link=@mysqli_connect($host,$user,$pass,$name) or die("数据库链接失败...");
mysqli_query($this->link,'set names utf8');
}

function query($sql){
return mysqli_query($this->link,$sql);
}

function fetch($query){
return mysqli\_fetch\_array($query);
}

function row($query){
$result=$this->query($query);
return mysqli\_fetch\_array($result);
}

function num($query){
return mysqli\_num\_rows($query);
}

function last_id(){
return mysqli\_insert\_id($this->link);
}
function error(){
return mysqli_error($this->link);
}
function close(){
return mysqli_close($this->link);
}


}

0%