Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class db
- {
- public $queries = 0;
- public $errors = array();
- function error()
- {
- $en = mysql_errno(); $e = mysql_error();
- if ( $en || $e ){
- $this->errors[] = $en . ' - ' . $e;
- }
- function __construct($svr, $usr, $pw, $db)
- {
- mysql_connect($svr, $usr, $pw);
- $this->error();
- mysql_select_db($db);
- $this->error();
- }
- function escape($str)
- {
- return mysql_real_escape_string($str);
- }
- function query($sql)
- {
- $this->queries++;
- $this->errors[] = 'Debug: ' . $sql;
- $result = mysql_query($sql);
- $this->error();
- return $result;
- }
- function rows($result)
- {
- $rows = mysql_num_rows($result);
- $this->error();
- return $rows;
- }
- function insert_id()
- {
- $id = mysql_insert_id();
- $this->error();
- return $id;
- }
- function affected_rows()
- {
- $rows = mysql_affected_rows();
- $this->error();
- return $rows;
- }
- function fetch($result)
- {
- $row = mysql_fetch_assoc($result);
- $this->error();
- return $row;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment