
youBBS 用mysqli 代替了 mysql
mysqli 在性能上提升了不少,以下是 /include/mysql.class.php 的新内容,如果你换上没问题就用它吧。
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
if(!defined('IN_SAESPOT')) exit('Access Denied');
class DB_MySQL {
var $querycount = 0;
var $link;
function connect($servername, $dbport, $dbusername, $dbpassword, $dbname) {
$this->link = mysqli_connect($servername, $dbusername, $dbpassword, $dbname, $dbport);
if (mysqli_connect_errno($this->link)) {
$this->halt("Failed to connect to MySQL: " . mysqli_connect_error());
exit();
}
mysqli_set_charset($this->link, "utf8");
mysqli_select_db($this->link, $dbname);
}
function geterrdesc() {
return mysqli_connect_error();
}
function geterrno() {
return intval(mysqli_connect_errno());
}
function insert_id() {
return ($id = mysqli_insert_id($this->link)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
}
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return mysqli_fetch_array($query, $result_type);
}
function query($sql) {
$query = mysqli_query($this->link, $sql);
$this->querycount++;
return $query;
}
function unbuffered_query($sql) {
$query = mysqli_query($this->link, $sql, MYSQLI_USE_RESULT);
$this->querycount++;
return $query;
}
function select_db($dbname) {
return mysqli_select_db($dbname, $this->link);
}
function fetch_row($query) {
$query = mysqli_fetch_row($query);
return $query;
}
function fetch_one_array($query) {
$result = $this->query($query);
$record = $this->fetch_array($result);
return $record;
}
function num_rows($query) {
$query = mysqli_num_rows($query);
return $query;
}
function num_fields($query) {
return mysqli_num_fields($query);
}
function result($query, $row) {
$query = @mysqli_result($query, $row);
return $query;
}
function free_result($query) {
$query = mysqli_free_result($query);
return $query;
}
function version() {
return mysqli_get_server_info($this->link);
}
function close() {
return mysqli_close($this->link);
}
function halt($msg ='', $sql=''){
$message = "<html>\n<head>\n";
$message .= "<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\">\n";
$message .= "<style type=\"text/css\">\n";
$message .= "body,p,pre {\n";
$message .= "font:12px Verdana;\n";
$message .= "}\n";
$message .= "</style>\n";
$message .= "</head>\n";
$message .= "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#006699\" vlink=\"#5493B4\">\n";
$message .= "<p>MySQL Database error:</p><pre><b>".htmlspecialchars($msg)."</b></pre>\n";
$message .= "<b>Mysql error description</b>: ".htmlspecialchars($this->geterrdesc())."\n<br />";
$message .= "<b>Mysql error number</b>: ".$this->geterrno()."\n<br />";
$message .= "<b>Date</b>: ".date("Y-m-d @ H:i")."\n<br />";
$message .= "<b>Script</b>: http://".$_SERVER['HTTP_HOST'].getenv("REQUEST_URI")."\n<br />";
$message .= "</body>\n</html>";
@header("content-Type: text/html; charset=UTF-8");
echo $message;
exit;
}
}
?>
注意!若使用mysqli 则必需删掉/install 文件,或修改一下这个文件:在 define('IN_SAESPOT', 1); 上面加一行exit('installed');
💘 相关文章
- 从MySQL转向PostgreSQL
- 90秒完成youBBS安装
- youBBS vps 版支持代码高亮了 HIGHLIGHT.JS
- google用不了,搜索也用不了了,目前有分享youbbs内容到微信或者微信圈的方案么?
- Can't connect to MySQL server on 'r.rdc.sae.sina.com.cn'
- youBBS for 普通PHP+mysql 空间 有地方下载么?
- YouBBS 怎么删帖
- 发现一个Simple Forum 和 youBBs 那个性能好呢 ,懂行的 来给讲讲 。
- 求问。 YOUBBS怎样做到防止灌水机器的入侵?可以有注册地范围控制吗?
- SAE mysql 用PHPMYADMIN导入数据时出现lock tables 解决方法
共1条关于"youBBS 用mysqli 代替了 mysql"的评论
不理解mysqli 和mysql有什么区别