Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MySQL {
- public $host;
- public $username;
- public $password;
- private $ref;
- public function mysql() {
- }
- public function connect($host, $username, $password) {
- $this->ref = @mysql_connect($host, $username, $password);
- $this->host = $host;
- $this->username = $username;
- $this->password = $password;
- if ($this->ref == false)
- return false;
- else
- return true;
- }
- public function escape($string) {
- $this->checkConnection();
- return @mysql_real_escape_string($string, $this->ref);
- }
- public function getError() {
- $this->checkConnection();
- return mysql_error($this->ref);
- }
- public function selectDB($db) {
- $this->checkConnection();
- $newRes = @mysql_select_db($db, $this->ref);
- if ($newRes == true)
- return true;
- else
- return false;
- }
- public function query($query) {
- $this->checkConnection();
- return @mysql_query($query, $this->ref);
- }
- public function getRows($query) {
- $this->checkConnection();
- $result = $this->query($query);
- return @mysql_num_rows($result);
- }
- public function returnArray($query) {
- $this->checkConnection();
- $result = $this->query($query);
- if (@mysql_num_rows($result) != 0) {
- $arr = array();
- while ($row = @mysql_fetch_assoc($result))
- $arr[] = $row;
- return $arr;
- } else
- return array();
- }
- public function checkConnection() {
- @$this->connect($this->host, $this->username, $this->password);
- }
- public function disconnect(){
- return @mysql_close($this->ref);
- }
- public function __destruct(){
- $this->disconnect();
- sleep(4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement