Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update table with column set NULL in codeigniter

i have a problem with update column with set data to NULL, i have a table user with each one column is id_parent column, user can delete parent and can add parent, so if user have a parent, id_parent will set with user's parent id , but user can delete parent's data, so if user delete parent's data, id_parent column, will set to NULL. so how to set data to null in database not " " but NULL. here's my user table.

user

id_user | name | address | id_parent
like image 585
nanasjr Avatar asked Dec 04 '22 03:12

nanasjr


1 Answers

use this to set null column.it will work, dont forget add false on third parameter SET on active record

$this->db->set('id_parent', 'NULL', false);
like image 55
ardani rahman Avatar answered Dec 23 '22 20:12

ardani rahman