-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.php
50 lines (44 loc) · 1016 Bytes
/
util.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
<?php
function connect()
{
$mysqli = new mysqli("localhost", "root", "", "bathtime");
// $mysqli = new mysqli("localhost", "root", "95luohui", "bathtime");
$mysqli->set_charset("utf8");
if ($mysqli->connect_errno) {
printf("Connect database failed: %s\n", $mysqli->connect_error);
exit();
}
return $mysqli;
}
function select($sql){
$mysqli = connect();
$result = $mysqli->query($sql);
$mysqli->close();
if(! $result ){
echo "select error";
exit();
}
return $result;
}
function insert($sql){
$mysqli = connect();
$mysqli->query($sql);
$result = $mysqli->affected_rows;
$mysqli->close();
return $result;
}
function delete($sql){
$mysqli = connect();
$mysqli->query($sql);
$result = $mysqli->affected_rows;
$mysqli->close();
return $result;
}
function update($sql){
$mysqli = connect();
$mysqli->query($sql);
$result = $mysqli->affected_rows;
$mysqli->close();
return $result;
}
?>