I have function which fetches data from external database and I get specific film information such as id, name, genre etc. Now if movie genre is for example Animation I want only this one genre to be added to db. Now I can solve issue using isset but then I will have db entries for genres null and I want to avoid this. What is best way to approach this problem? Using foreach loop?
$records = array(
array('film_id' => $movies['id'], 'genre_id' => $movies['genre'][0]),
array('film_id' => $movies['id'], 'genre_id' => $movies['genre'][1]),
array('film_id' => $movies['id'], 'genre_id' => $movies['genre'][2])
);
$this->db->insert_batch('film_genre', $records);