]>
git.wh0rd.org - tt-rss.git/blob - classes/db/mysqli.php
a05b121fcf694bfa73d3ee89b8ff5d03c66644c6
2 class Db_Mysqli
implements IDb
{
6 function connect($host, $user, $pass, $db, $port) {
8 $this->link
= mysqli_connect($host, $user, $pass, $db, $port);
10 $this->link
= mysqli_connect($host, $user, $pass, $db);
17 print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error());
22 function escape_string($s, $strip_tags = true) {
23 if ($strip_tags) $s = strip_tags($s);
25 return mysqli_real_escape_string($this->link
, $s);
28 function query($query, $die_on_error = true) {
29 $result = @mysqli_query
($this->link
, $query);
31 $this->last_error
= @mysqli_error
($this->link
);
33 @mysqli_query
($this->link
, "ROLLBACK");
34 user_error("Query $query failed: " . ($this->link ?
$this->last_error
: "No connection"),
35 $die_on_error ? E_USER_ERROR
: E_USER_WARNING
);
41 function fetch_assoc($result) {
42 return mysqli_fetch_assoc($result);
46 function num_rows($result) {
47 return mysqli_num_rows($result);
50 function fetch_result($result, $row, $param) {
51 if (mysqli_data_seek($result, $row)) {
52 $line = mysqli_fetch_assoc($result);
60 return mysqli_close($this->link
);
63 function affected_rows($result) {
64 return mysqli_affected_rows($this->link
);
67 function last_error() {
68 return mysqli_error($this->link
);
71 function last_query_error() {
72 return $this->last_error
;
76 $this->query("SET time_zone = '+0:0'");
78 if (defined('MYSQL_CHARSET') && MYSQL_CHARSET
) {
79 mysqli_set_charset($this->link
, MYSQL_CHARSET
);