Advertisement
Protocol_

OCPMysql

Apr 12th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2. class MySQL {
  3.     private $ref;
  4.     public function __construct(&$ref) {
  5.         $this->ref = &$ref;
  6.     }
  7.     public function escape($string) {
  8.         return mysql_real_escape_string($string, $this->ref);
  9.     }
  10.     public function getError() {
  11.         return mysql_error($this->ref);
  12.     }
  13.     public function selectDB($db) {
  14.         return (mysql_select_db($db, $this->ref))?true:false;
  15.     }
  16.     public function query($query) {
  17.         return @mysql_query($query, $this->ref)or print("Erro: ".mysql_error()."\n");
  18.     }
  19.     public function getRows($query) {
  20.         return mysql_num_rows($this->query($query));
  21.     }
  22.     public function returnArray($query) {
  23.         $result = (is_resource($query))?$query:mysql_query($query);
  24.         $arr = array();
  25.         while($row = mysql_fetch_assoc($result)) $arr[] = $row;
  26.         return $arr;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement