04-12-2012, 01:16 AM
[eluser]mflammia[/eluser]
Hi,
When updating a record using the code below it seems to replace all items with a 0?
The echo $str looks like the following:
Regardless of whats in the table, whether some fields have entries or are blank the update sets them all to zero's?
Any ideas?
Hi,
When updating a record using the code below it seems to replace all items with a 0?
Code:
function update_recordP($updateID,$person)
{
$this->db->where ('id_person',$updateID);
$this->db->update('person', $person);
$str = $this->db->last_query();
echo $str;
return;
}
The echo $str looks like the following:
Code:
UPDATE `person` SET `first_name` = 'Joe', `second_name` = 'Bloggs', `dob` = '1972-08-11', `phone` = '', `email` = '' WHERE `id_person` = '5'
Code:
+-------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+----------------+
| id_person | int(11) | NO | PRI | NULL | auto_increment |
| first_name | varchar(50) | YES | | NULL | |
| second_name | varchar(50) | YES | | NULL | |
| dob | date | NO | | NULL | |
| email | varchar(80) | YES | | NULL | |
| phone | varchar(20) | YES | | NULL | |
+-------------+-------------+------+-----+---------+----------------+
Regardless of whats in the table, whether some fields have entries or are blank the update sets them all to zero's?
Any ideas?