Oke, 제목에서 제안하는 바와 같이 하나의 데이터베이스 필드에 중첩 배열의 여러 값을 삽입하려고합니다.Codeigniter - 데이터베이스에 중첩 배열의 다중 값을 삽입합니다.
아래의 배열은 내 데이터베이스의 여러 레코드가 아닌 하나의 레코드에 저장됩니다.
내 어레이 모양입니다.
array(5) {
["stars"]=>
array(5) {
[0]=>
string(10) "Chris Pine"
[1]=>
string(14) "Zachary Quinto"
[2]=>
string(11) "Zoe Saldana"
[3]=>
string(10) "Karl Urban"
[4]=>
string(10) "Simon Pegg"
}
["directors"]=>
array(1) {
[0]=>
string(11) "J.J. Abrams"
}
["writers"]=>
array(4) {
[0]=>
string(12) "Roberto Orci"
[1]=>
string(13) "Alex Kurtzman"
[2]=>
string(14) "Damon Lindelof"
[3]=>
string(16) "Gene Roddenberry"
}
["genres"]=>
array(4) {
[0]=>
string(6) "Action"
[1]=>
string(9) "Adventure"
[2]=>
string(6) "Sci-Fi"
[3]=>
string(8) "Thriller"
}
["movie_data"]=>
array(12) {
["imdb_id"]=>
string(9) "tt1408101"
["slug"]=>
string(23) "star-trek-into-darkness"
["title"]=>
string(23) "Star Trek Into Darkness"
["imdb_rating"]=>
string(3) "8.2"
["release_date"]=>
string(11) "6 June 2013"
["runtime"]=>
string(4) "132m"
["mpaa_rating"]=>
string(5) "PG-13"
["storyline"]=>
string(554) "When the crew of the Enterprise is called back home, they find an unstoppable force of terror from within their own organization has detonated the fleet and everything it stands for, leaving our world in a state of crisis. With a personal score to settle, Captain Kirk leads a manhunt to a war-zone world to capture a one man weapon of mass destruction. As our heroes are propelled into an epic chess game of life and death, love will be challenged, friendships will be torn apart, and sacrifices must be made for the only family Kirk has left: his crew."
["plot"]=>
string(202) "After the crew of the Enterprise find an unstoppable force of terror from within their own organization, Captain Kirk leads a manhunt to a war-zone world to capture a one man weapon of mass destruction."
["poster_large"]=>
bool(false)
["poster"]=>
string(97) "http://ia.media-imdb.com/images/M/[email protected]@._V1._SY500.jpg"
["trailer"]=>
string(157) "http://www.youtube.com/v/QAEkuVgt6Aw&feature=youtube_gdata_player?color2=FBE9EC&hd=1&autoplay=1&showsearch=0&version=3&modestbranding=1&fs=1&iv_load_policy=3"
}
}
나는 일반적인 배열 내부의 "별"라는 배열을 가지고 내 데이터베이스에서 하나 개의 필드에서 그 "별"배열의 모든 값을합니다. 쉬운 검색과 검색을 위해 별이라고도합니다.
나는 codeigniters batch_insert 함수를 살펴 봤지만 필요가 없으면하고 싶지 않습니다.
앞으로 나아갈 수있는 방법을 누군가가 최소한 올바른 방향으로 가르쳐 주길 바랍니다.
미리 감사드립니다.
친절하게 설명 된 답변에 감사드립니다. 내 데이터베이스가 어떻게 구조화 될지 다시 생각해야합니다. 이제 문자열의 모든 액터를 압축하는 foreach 루프가 있습니다. 그러나 나는 당신의 생각이 더 나은 해결책이라고 생각합니다. ;) – user1928075