Welcome Guest, Not a member yet? Register   Sign In
CI 2.0 -> Active record -> Replacing blank with 0?
#1

[eluser]JasonS[/eluser]
I don't think I am being stupid here.

Here is my code.

Code:
$db = array (
    'content' => $this->ci->input->post('content'),
    'seo_keywords' => $this->ci->input->post('seo_keywords'),
    'seo_description' => $this->ci->input->post('seo_description'),
    'seo_title' => $this->ci->input->post('seo_title'),
);

foreach($db as $field => $value) {
    echo $value . '<br />';
    $this->ci->db->where('name', $field)->where('page_id', $page->id)->set('value', $value)->update('page_fields');
    echo $this->ci->db->last_query() . '<br />';
}

Only the content field has any input in it. This creates the following output.

Quote:Test
UPDATE `page_fields` SET `value` = 'Test' WHERE `name` = 'content' AND `page_id` = '1'

UPDATE `page_fields` SET `value` = 0 WHERE `name` = 'seo_keywords' AND `page_id` = '1'

UPDATE `page_fields` SET `value` = 0 WHERE `name` = 'seo_description' AND `page_id` = '1'

UPDATE `page_fields` SET `value` = 0 WHERE `name` = 'seo_title' AND `page_id` = '1'

Surely this should be `value` = ''?


Messages In This Thread
CI 2.0 -> Active record -> Replacing blank with 0? - by El Forum - 09-08-2010, 02:21 AM
CI 2.0 -> Active record -> Replacing blank with 0? - by El Forum - 09-08-2010, 07:02 AM
CI 2.0 -> Active record -> Replacing blank with 0? - by El Forum - 09-08-2010, 07:12 AM
CI 2.0 -> Active record -> Replacing blank with 0? - by El Forum - 09-08-2010, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB