Welcome Guest, Not a member yet? Register   Sign In
Setting a value to null with Active Record
#2

[eluser]beatryder[/eluser]
[quote author="rkhalife" date="1193892216"]Hi,

I'm trying to set a value to NULL in the database through ActiveRecord.
Code:
$this->db->set('phone_2',NULL);
$this->db->where('id',$uid);
$this->db->update('user');

Unfortunately, the set function in the active record module is defined like this.
So it ends up setting the value to the empty string instead of NULL.
Code:
function set($key, $value = '')

I guess I could write the whole query myself, but I would rather use active record.
Is there a way around this?

Thanks,
-Raymond[/quote]


Sure
try this:
Code:
$this->db->set('phone_2','NULL'); //using the quotes usually works for me.
$this->db->where('id',$uid);
$this->db->update('user');


Messages In This Thread
Setting a value to null with Active Record - by El Forum - 10-31-2007, 05:43 PM
Setting a value to null with Active Record - by El Forum - 10-31-2007, 10:24 PM
Setting a value to null with Active Record - by El Forum - 11-01-2007, 11:45 AM
Setting a value to null with Active Record - by El Forum - 11-01-2007, 12:55 PM
Setting a value to null with Active Record - by El Forum - 11-01-2007, 01:14 PM
Setting a value to null with Active Record - by El Forum - 11-01-2007, 01:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB