1
Hello, beauty?
I’m making a update in a table and I am sending the data array. However, I have a date field. Every time I update, it sends the field as 'dtnascimento' = ''
. When this data arrives in the database, my database arrow the date as 0000-00-00
.
What I wish to do: make a check if my the position of my array is null. If null, set the value to arrive in the database as (NULL).
Below my current code:
function atualizarFuncionario($dados){
if ($dados['dtnascimento'] === '') {
$dados['dtnascimento'] = NULL;
}
$where = array(
'idfuncionario' => $dados['idfuncionario'],
'idempresa' => $dados['idempresa']
);
$this->db->update($this->tabela,html_escape($dados),$where);
}
If anyone knows, a moral there rs
Failed to check if null or pass value
null
to the bank?– rray
@rray already tried it and it happens the same thing that I quoted in the second line,
'dtnascimento' = ''
.– Matheus Velloso
I did some tests with the PDO, recorded null when I passed
null
or'null'
, blank turned out to be like0000-00-00
– rray
Changes the field
data
for date NULL format, and when you add, pass the field as 'NULL' as well– Sr. André Baill