I need to increase the value of a field in my CodeIgniter database.
I understand that CI allows not to escape values, setting as FALSE the third parameter in $this->db->set().
I am inserting multiple data from an array, and as I understand, it would be not much secure to escape them all (data is coming from form), since I only need increasing in one field.
How can I avoid inserting this value separately?
My current code:
$dataCliente = array(
'nombre' => $nombre,
'email' => $email,
'genero' => $genero,
'reserva_next' => $fecha,
'reserva_next_id' => $reserva_id,
'reserva_lastreq' => time(),
'reservas' => "reservas+1"
);
$this->db->where('telefono', $telefono);
$this->db->update('clientes', $dataCliente);
EDIT: I HAVE TESTED WITH SIMPLE AND DOUBLE QUOTES, IN BOTH CASES THE VALUE OF THE FIELD IS SAVED AS 0 (ZERO)
The previous code does not produce the expected result. But this works:
$dataCliente = array(
'nombre' => $nombre,
'email' => $email,
'genero' => $genero,
'reserva_next' => $fecha,
'reserva_next_id' => $reserva_id,
'reserva_lastreq' => time(),
//'reservas' => "reservas+1"
);
$this->db->where('telefono', $telefono);
$this->db->update('clientes', $dataCliente);
$this->db->set('reservas', 'reservas+1', FALSE);
$this->db->where('telefono', $telefono);
$this->db->update('clientes', $dataCliente);
My intention is to use only one statement to insert data. Is it possible not to escape a single element of the array, using the first code?
Thank you very much!