Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php
  2. class DBConexion
  3. {
  4.      public $link;
  5.      
  6.      public function __construct($host='', $user='', $pass='', $db='')
  7.      {
  8.           $this->link = mysql_connect($host, $user, $pass) or die (mysql_error());
  9.           mysql_select_db($db, $this->link) or die (mysql_error());
  10.      }
  11.      
  12.      public function query($strQuery)
  13.      {
  14.           $resource = mysql_query($strQuery, $this->link) or die (mysql_error());
  15.           return $resource;
  16.      }
  17.      
  18.      public function numRows($resource)
  19.      {
  20.           $nRows = mysql_num_rows($resource);
  21.  
  22.           if($nRows)
  23.                return $nRows;
  24.           else
  25.                return 0;
  26.      }
  27.      
  28.      public function fetchAssoc($resource)
  29.      {
  30.           $rows = mysql_fetch_assoc($resource);
  31.           return $rows;
  32.      }
  33.      
  34.      public function fetchRow($resource)
  35.      {
  36.           $rows = mysql_fetch_row($resource) or die (mysql_error());
  37.           return $rows;
  38.      }
  39.      
  40.      public function affectedRows($resource)
  41.      {
  42.           $nRows = mysql_affected_rows($resource) or die (mysql_error());
  43.          
  44.           return $nRows;
  45.      }
  46.      
  47.      public function limpiarEntrada($string)
  48.      {
  49.           return mysql_real_escape_string($string);
  50.      }
  51.      
  52.      public function close()
  53.      {
  54.           mysql_close($this->link);
  55.           unset($this->link);
  56.      }
  57. }
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement