Ver Mensaje Individual
  #10 (permalink)  
Antiguo 29/05/2016, 13:14
Avatar de Benderzuelo
Benderzuelo
 
Fecha de Ingreso: mayo-2013
Ubicación: España
Mensajes: 223
Antigüedad: 11 años
Puntos: 5
Respuesta: Después de un UPDATE no continúa WHILE

Código PHP:
Ver original
  1. class Mysql {
  2.    
  3.     private $server; // Servidor donde está alojada la BBDD
  4.     private $user;   // Usuario que se conecta a la BBDD
  5.     private $passwd; // Contraseña del usuario que se conecta a la BBDD
  6.     private $bbdd;   // Nombre de la BBDD a la que se quiere conectar
  7.     private $link;   // Puntero a la BBDD (por si se abre conexión a varias BBDD)
  8.     private $error;  // Guarda el resultado de mysql_error()
  9.    
  10. function __construct($server, $user, $passwd, $bbdd) {
  11.         $this->server = $server;
  12.         $this->user   = $user;
  13.         $this->passwd = $passwd;
  14.         $this->bbdd   = $bbdd;
  15.         $this->conecta();
  16.     }
  17.    
  18.    private function conecta() {
  19.         $this->link = mysqli_connect($this->server, $this->user, $this->passwd);
  20.         mysqli_select_db($this->link,$this->bbdd);
  21.         mysqli_query($this->link, "SET NAMES utf8");
  22.     }
  23.    
  24.    
  25. public function muestraError() {
  26.         return $this->error;
  27.     }
  28.    
  29.  
  30. public function ejecutaSql($qry) {
  31.         if (!$this->res = mysqli_query($this->link, $qry)) {
  32.             //Preparo el error
  33.             $this->error = mysqli_error($this->link);
  34.             return false;
  35.         }else{
  36.             return true;
  37.         }
  38.     }
  39.    
  40.    
  41. public function asociaFilas() {
  42.         if (!$row = mysqli_fetch_assoc($this->res)) {
  43.             $this->error = mysqli_error($this->link);
  44.             return false;
  45.         }else{
  46.            return $row;
  47.         }
  48.     }
  49.    
  50. public function numeroFilas() {
  51.         return mysqli_num_rows($this->res);
  52.     }
  53.    
  54.    
  55. public function filasAfectadas() {
  56.         return mysqli_affected_rows($this->link);
  57.     }
  58.    
  59.    
  60.    
  61.  
  62. public function ultimoID() {
  63.         return mysqli_insert_id($this->link);
  64.     }
  65.  
  66.    
  67. public function cierraCNX(){
  68.         if(mysqli_close($this->link)){
  69.             return true;
  70.         }else{
  71.             return false;
  72.         }
  73.     }
  74. }