]>
git.wh0rd.org - tt-rss.git/blob - classes/db/mysqli.php
e82f6630007fed0f211c00c20fff1bbb84e955b1
2 class Db_Mysqli
implements IDb
{
5 function connect($host, $user, $pass, $db, $port) {
6 $this->link
= mysqli_connect($host, $user, $pass, $db, $port);
13 die("Unable to connect to database (as $user to $host, database $db): " . mysqli_error());
17 function escape_string($s, $strip_tags = true) {
18 if ($strip_tags) $s = strip_tags($s);
20 return mysqli_real_escape_string($this->link
, $s);
23 function query($query, $die_on_error = true) {
24 $result = mysqli_query($this->link
, $query);
26 user_error("Query $query failed: " . ($this->link ?
mysqli_error($this->link
) : "No connection"),
27 $die_on_error ? E_USER_ERROR
: E_USER_WARNING
);
33 function fetch_assoc($result) {
34 return mysqli_fetch_assoc($result);
38 function num_rows($result) {
39 return mysqli_num_rows($result);
42 function fetch_result($result, $row, $param) {
43 if (mysqli_data_seek($result, $row)) {
44 $line = mysqli_fetch_assoc($result);
52 return mysqli_close($this->link
);
55 function affected_rows($result) {
56 return mysqli_affected_rows($this->link
);
59 function last_error() {
60 return mysqli_error();
64 $this->query("SET time_zone = '+0:0'");
66 if (defined('MYSQL_CHARSET') && MYSQL_CHARSET
) {
67 $this->query("SET NAMES " . MYSQL_CHARSET
);