如何将其插入数据库?
我有这个文件:
[player_id] => 70658
[mobile_number] => 09********
[name] => gorbani
[password] => ******
[verification_code] => KUTY6U
[subscription] => 0
[gold] => 147350
[date_joined] => 2011-04-26 20:02:40
[free_spin] => 0
[player_status] => 1
[scriptedSpin] => PLG
[message_flag] => N
[gold_award] => 0
这只是一个文本文件中 300,000 个或更多条目中的 1 个条目。我需要自动插入ff。进入一个mysql db,其中只有
mobile_number
name
password
gold
将被取出并插入。
谢谢你。
问候, Mehihi
这就是文件的格式:
[player_id] => 70658
[mobile_number] => 09********
[name] => gorbani
[password] => ******
[verification_code] => KUTY6U
[subscription] => 0
[gold] => 147350
[date_joined] => 2011-04-26 20:02:40
[free_spin] => 0
[player_status] => 1
[scriptedSpin] => PLG
[message_flag] => N
[gold_award] => 0
[player_id] => 70659
[mobile_number] => 09********
[name] => gorbani2
[password] => ******
[verification_code] => 22222
[subscription] => 0
[gold] => 147350
[date_joined] => 2011-04-26 20:02:40
[free_spin] => 0
[player_status] => 1
[scriptedSpin] => PLG
[message_flag] => N
[gold_award] => 0
等等..
我试过这个但没有用:
$sql = array();
foreach( $myarray as $row ) {
$sql[] = '('.$row['ID'].', "'.mysql_real_escape_string($row['NAME']).'","'.$row['PRICE'].'")';}
mysql_real_query('INSERT INTO table (ID, NAME,PRICE) VALUES '.implode(',', $sql));