Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/07/2015, 16:26
Avatar de hhs
hhs
Colaborador
 
Fecha de Ingreso: junio-2013
Ubicación: México
Mensajes: 2.995
Antigüedad: 10 años, 10 meses
Puntos: 379
Respuesta: Evitar UPDATE si el input está vacío

Código PHP:
Ver original
  1. $postData = array(
  2.     'color' => 'azul',
  3.     'precio' => 50,
  4.     'stock' => '',
  5. );
  6.  
  7. $_POST = $postData;
  8.  
  9. function allInputsComplete(Array $post, $elements)
  10. {
  11.     $inputs = array_filter($post);
  12.  
  13.     if (count($inputs) < $elements) {
  14.         return false;
  15.     }
  16.  
  17.     return true;
  18. }
  19.  
  20. if (AllInputsComplete($_POST, 3)) {
  21.     echo 'Actualizado';
  22. } else {
  23.     echo 'No Actualizado';
  24. }
__________________
Saludos
About me
Laraveles
A class should have only one reason to change.