How to update specific field in CodeIgniter update?
In my above function I pass only the $appointment_id, so the variable $appointment is empty and doesn't contain any associative array.
If you simply want to update the column data
to 1
for appointment_id 0
then pass in an array with data
for the key and 1
for the value.
$appointment_id = 0;
$appointment = array('data' => 1);
$this->db->where('id', $appointment_id);
$this->db->update('ea_appointments', $appointment);
Dillinger
Solve a problem and then another and when you have solved enough you will be ready for release!
Updated on June 17, 2022Comments
-
Dillinger almost 2 years
I'm using
CodeIgniter
framework for theeasyappointments.org
library. I'm trying to update the fielddata
through the id of a row. Actually this is my code for the update:return $this->db ->update('ea_appointments', $appointment) ->where('ea_appointments.id', $appointment_id);
The problem's that the
update
method need two parameter (table to update, associative array with the fields name column of db). In my above function I pass only the$appointment_id
, so the variable$appointment
is empty and doesn't contain any associative array. I want to know how to update only the fielddata
to1
. And remain the other field in the same value condition. This is the structure of the table:id|book|start|end|notes|hash|unavailable|provider|data
Logic example:
previous condition row:
id => 0 book => example start => 18/10/2015 end => 19/10/2015 notes => empty hash => akdjasldja unavailable => false provider => 5 data => 0
I pass in the function
$appointment_id
with 0 value. I'm waiting this new result:id => 0 book => example start => 18/10/2015 end => 19/10/2015 notes => empty hash => akdjasldja unavailable => false provider => 5 data => 1
So the main problem is retrieve first the all field value of the specific row and later update? Or something like this. Could someone help me?