Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/03/2014, 10:39
Avatar de NSD
NSD
Colaborador
 
Fecha de Ingreso: mayo-2012
Ubicación: Somewhere
Mensajes: 1.332
Antigüedad: 12 años, 10 meses
Puntos: 320
Respuesta: Bind_param variable null

Hola, no, creo que no explique para nada bien, lo que quiero es hacer esto:

Código PHP:
Ver original
  1. <?php
  2. $mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world');
  3.  
  4.     printf("Error de conexión: %s\n", mysqli_connect_error());
  5.     exit();
  6. }
  7. // La sentencia puede ser "SELECT * FROM test WHERE activo IS NULL;" o "SELECT * FROM test WHERE activo IS NOT NULL;"
  8. $null_estado = 'NULL'; // 'NULL' o 'NOT NULL'
  9. $stmt = $mysqli->prepare("SELECT * FROM test WHERE activo IS ?;");
  10. $stmt->bind_param('s', $null_estado);
  11.  
  12. $stmt->execute();

Lo hice andar usando la funcion ISNULL asi:

Código PHP:
Ver original
  1. <?php
  2. $mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world');
  3.  
  4.     printf("Error de conexión: %s\n", mysqli_connect_error());
  5.     exit();
  6. }
  7.  
  8. $null_estado = 1;
  9. $stmt = $mysqli->prepare("SELECT * FROM test WHERE ISNULL(activo) = ?;");
  10. $stmt->bind_param('i', $null_estado);
  11.  
  12. $stmt->execute();
__________________
Maratón de desafíos PHP Junio - Agosto 2015 en FDW | Reglamento - Desafios