Welcome Guest, Not a member yet? Register   Sign In
Saving an Array to Database
#1

[eluser]RMinor[/eluser]
Maybe it's just late and my brain is fried, but I can't seem to figure out how to take the contents of the array below and save it into my database table. Here is the array:
Code:
print_r($insert_data);

Array ( [photo] => Array ( [0] => large_pic24.jpg [1] => large_pic25.jpg [2] => large_pic26.jpg [3] => large_pic27.jpg ) [thumbnail] => Array ( [0] => large_pic24_thumb.jpg [1] => large_pic25_thumb.jpg [2] => large_pic26_thumb.jpg [3] => large_pic27_thumb.jpg ) )

The controller code will take each photo and insert it into the database. Here is the model that will be saving each photo and thumbnail:
Code:
public function insertPhoto($photo, $thumbnail, $person_id)
{
    $data = array (
        'photo_photo'   => $photo,
        'photo_thumbnail'  => $thumbnail,
        'photo_person'   => $person_id
    };
    $this->db->insert('photo', $data);
    if ($this->db->affected_rows() == 1) {
        return TRUE;
    }
    return FALSE;
}

Can somebody help me out here? Thanks in advance.


Messages In This Thread
Saving an Array to Database - by El Forum - 10-05-2012, 10:48 PM
Saving an Array to Database - by El Forum - 10-05-2012, 10:55 PM
Saving an Array to Database - by El Forum - 10-05-2012, 11:11 PM
Saving an Array to Database - by El Forum - 10-05-2012, 11:51 PM
Saving an Array to Database - by El Forum - 10-06-2012, 12:29 AM
Saving an Array to Database - by El Forum - 10-06-2012, 12:46 AM
Saving an Array to Database - by El Forum - 10-06-2012, 01:16 AM
Saving an Array to Database - by El Forum - 10-06-2012, 02:44 AM
Saving an Array to Database - by El Forum - 10-06-2012, 10:57 AM
Saving an Array to Database - by El Forum - 10-06-2012, 11:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB