fork download
  1. <?php
  2.  
  3. $_POST = [
  4. "ambiente" => "",
  5. "logotipo" => "Novo logotipo",
  6. "certificado" => "",
  7. "senha" => ""
  8. ];
  9.  
  10. $id = 1;
  11.  
  12. $data = array_filter($_POST);
  13.  
  14. $fields = array_map(function ($value, $key) {
  15. return sprintf("`%s`='%s'", $key, $value);
  16. }, $data, array_keys($data));
  17.  
  18. $query = sprintf("UPDATE `tabela` SET %s WHERE `id`=%d", implode(",", $fields), $id);
  19.  
  20. echo $query, PHP_EOL;
Success #stdin #stdout 0.02s 82880KB
stdin
Standard input is empty
stdout
UPDATE `tabela` SET `logotipo`='Novo logotipo' WHERE `id`=1