Guest User

Untitled

a guest
Nov 25th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. private static $db_host = 'localhost';
  2. private static $db_user = '';
  3. private static $db_pass = '';
  4. private $db_name = '';
  5. private $conexion;
  6. private $resultado;
  7.  
  8. public function __construct()
  9. {
  10. $this->conectar();
  11. }
  12.  
  13. protected function conectar()
  14. {
  15.  
  16. $this->conexion = mysqli_connect(
  17. self::$db_host,
  18. self::$db_user,
  19. self::$db_pass,
  20. $this->db_name);
  21.  
  22. if (!$this->conexion) {
  23. mysqli_error($this->conexion);
  24. } else {
  25. return true;
  26. }
  27. }
  28.  
  29. protected function query($sql)
  30. {
  31. $this->resultado = mysqli_query($this->conexion, $sql);
  32. if (!$this->resultado) {
  33. die('error: query ' . mysql_error());
  34. }
  35.  
  36. }
  37.  
  38. protected function extraerRegistro()
  39. {
  40. $fila = mysqli_fetch_assoc($this->resultado);
  41. return $fila;
  42. }
  43.  
  44. public function affected()
  45. {
  46.  
  47. $num = mysqli_affected_rows($this->conexion);
  48. if ($num) {
  49. return true;
  50. } else {
  51. return false;
  52. }
  53.  
  54. }
Add Comment
Please, Sign In to add comment