Answer the question
In order to leave comments, you need to log in
Entering data into two tables, Codeigniter. How?
I enter the data into the database, the notice climbs:
Message: Array to string conversion
Code:
$status = $this->db->insert($this->table_name, $data);
$data_genres = array(
'series_id' => $this->db->insert_id(),
'genre_id' => $this->input->post('genres')
);
$status = $this->db->insert($this->table_genres, $data_genres);
array(13) { ["poster"]=> string(0) "" ["name"]=> string(4) "test" ["original_name"]=> string(0) "" ["year"]=> string(1) "1" ["country"]=> string(0) "" ["director"]=> string(0) "" ["producer"]=> string(0) "" ["actors"]=> string(5) "test1" ["description"]=> string(5) "test2" ["translation"]=> string(0) "" ["status"]=> string(7) "option1" ["created_on"]=> string(19) "2016-05-11 21:40:59" ["created_by"]=> int(1) }
Array ( [series_id] => 35 [genre_id] => Array ( [0] => 6 [1] => 7 ) )
Answer the question
In order to leave comments, you need to log in
$status = $this->db->insert($this->table_name, $data);
$seriesId =$this->db->insert_id();
$genres = $this->input->post('genres');
foreach ($genres as $genreId) {
$data_genres = array(
'series_id' => $seriesId,
'genre_id' => $genreId,
);
$status = $this->db->insert($this->table_genres, $data_genres);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question