您好我有一个包含1000个(.sql)文件的目录,我试图让php脚本在sql中提取所有文件。
这看起来像这样......
2013_07_17_00_world_version.sql 2013_07_17_01_world_conditions.sql 2013_07_17_02_world_gossip.sql 2013_07_17_03_world_gossip.sql 2013_07_17_04_world_spell_script_names.sql 2013_07_18_00_world_conditions.sql 2013_07_18_01_world_koralon.sql 2013_07_18_02_world_spell_script_names.sql 2013_07_18_02_world_the_flesh_giant_slayer.sql 2013_07_18_03_world_equipment.sql 2013_07_19_00_world_misc.sql 2013_07_20_00_world_gameobject.sql 2013_07_20_01_world_misc.sql 2013_07_23_00_world_misc.sql 2013_07_23_02_world_creature_template.sql 2013_07_24_00_world_spell_script_names.sql 2013_07_24_01_world_spell_ranks_335.sql 2013_07_24_02_world_trinity_strings.sql 2013_07_24_03_world_spell_proc_event_335.sql 2013_07_25_00_world_spell_script_names.sql
我的策略是首先获取文件名并将该名称放入查询中,但我做错了。 Any1有想法或者软件怎么能拉多..
我的代码是:
<?php
$path = 'updates/world';
$user = 'root';
$pass = 'socvbe';
$host = 'localhost';
$base = 'world';
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($base) or die(mysql_error());
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
//echo "$entry\n<br>";
mysql_query($entry) or die('error in query');
}
}
closedir($handle);
}
?>