]>
git.wh0rd.org - tt-rss.git/blob - classes/db/mysql.php
2 class Db_Mysql
implements IDb
{
5 function connect($host, $user, $pass, $db, $port) {
6 $this->link
= mysql_connect($host, $user, $pass);
9 $result = mysql_select_db($db, $this->link
);
11 die("Can't select DB: " . mysql_error($this->link
));
18 die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
22 function escape_string($s, $strip_tags = true) {
23 if ($strip_tags) $s = strip_tags($s);
25 return mysql_real_escape_string($s, $this->link
);
28 function query($query, $die_on_error = true) {
29 $result = mysql_query($query, $this->link
);
31 user_error("Query $query failed: " . ($this->link ?
mysql_error($this->link
) : "No connection"),
32 $die_on_error ? E_USER_ERROR
: E_USER_WARNING
);
37 function fetch_assoc($result) {
38 return mysql_fetch_assoc($result);
42 function num_rows($result) {
43 return mysql_num_rows($result);
46 function fetch_result($result, $row, $param) {
47 return mysql_result($result, $row, $param);
51 return mysql_close($this->link
);
54 function affected_rows($result) {
55 return mysql_affected_rows($this->link
);
58 function last_error() {
63 $this->query("SET time_zone = '+0:0'");
65 if (defined('MYSQL_CHARSET') && MYSQL_CHARSET
) {
66 $this->query("SET NAMES " . MYSQL_CHARSET
);