好的,正如标题所示,我想在一个数据库字段中插入嵌套数组中的多个值。
为了清楚起见,下面的数组将在我的数据库中的一条记录中,而不是在多行中。
这就是我的数组的样子。
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/MV5BMTk2NzczOTgxNF5BMl5BanBnXkFtZTcwODQ5ODczOQ@@._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"
}
}
我在一个通用数组中有一个名为“stars”的数组,并且希望该“stars”数组中的所有值都在我的数据库的一个字段中。当然称为星号,以便于匹配和搜索。
我查看了 codeigniters batch_insert 函数,但它并不希望我需要它来做。
我希望有人至少可以为我指明如何进行的正确方向。
先感谢您。