Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class database
- {
- private $host;
- private $user;
- private $pass;
- private $db;
- function __CONSTRUCT($host,$user,$pw,$db)
- {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pw;
- $this->db = $db;
- }
- public function connect()
- {
- if(mysql_connect($this->host,$this->user,$this->pass) AND mysql_select_db($this->db))
- {
- return true;
- }
- return mysql_error();
- }
- public function close()
- {
- if(mysql_close($this->db))
- {
- return true;
- }
- return false;
- }
- public function escape($str)
- {
- return mysql_escape_string($str);
- }
- public function query($q)
- {
- if(mysql_query($q))
- {
- return true;
- }
- return mysql_error();
- }
- public function fetch($t,$q)
- {
- switch($t)
- {
- case 'assoc':
- return mysql_fetch_assoc($q);
- break;
- case 'array':
- return mysql_fetch_array($q);
- break;
- case 'row':
- return mysql_fetch_row($q);
- break;
- }
- }
- public function num_rows($q)
- {
- return mysql_num_rows($q);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment