| From: | Halley Pacheco de Oliveira <halleypo(at)yahoo(dot)com(dot)br> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Cc: | "Matt A(dot)" <survivedsushi(at)yahoo(dot)com> |
| Subject: | Re: question |
| Date: | 2005-08-30 13:43:33 |
| Message-ID: | 20050830134333.31428.qmail@web52713.mail.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
In PHP I use this code with a prepared statement to insert null in the field justif_emenda when
the value in the form is an empty string or a string with only spaces. I hope this will help you.
$sql = "INSERT INTO tbl_emenda ("
. "id_emenda, subtipo_emenda, tipo_emenda, "
. "nome_autor, titulo_autor, login_autor, "
. "cod_acao_gov, nome_acao_gov, "
. "texto_emenda, justif_emenda) "
. "VALUES(?,?,?,?,?,?,?,?,?,nullif(trim(' ' from ?),''))";
$stmt = $conn->Prepare($sql);
if (!$conn->Execute($stmt, array(
$id_emenda,
'S',
'Aditiva',
$_SESSION['nome_autor'],
$_SESSION['titulo_autor'],
$_SESSION['login_autor'],
$_REQUEST['selCodAcaoGov'],
$_REQUEST['txtNomeAcaoGov'],
$_REQUEST['txtTexto'],
$_REQUEST['txtJustif']
))) {
erroSQL($conn, $sql);
die("Erro..");
}
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vivek Khera | 2005-08-30 14:59:01 | Re: question |
| Previous Message | Greg Stark | 2005-08-30 13:17:42 | Re: ALTER TABLE ( smallinto -> boolean ) ... |