<分区>
我正在读取 csv 并使用 mysql 检查记录是否存在于我的表中或是否存在于 php 中。
csv 有近 25000 条记录 & 当我运行我的代码时它在 2m 10s 后显示“服务不可用”错误(加载:2m 10s)
这里我添加了代码
// for set memory limit & execution time
ini_set('memory_limit', '512M');
ini_set('max_execution_time', '180');
//function to read csv file
function readCSV($csvFile)
{
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle) ) {
set_time_limit(60); // you can enable this if you have lot of data
$line_of_text[] = fgetcsv($file_handle, 1024);
}
fclose($file_handle);
return $line_of_text;
}
// Set path to CSV file
$csvFile = 'my_records.csv';
$csv = readCSV($csvFile);
for($i=1;$i<count($csv);$i++)
{
$user_email= $csv[$i][1];
$qry = "SELECT u.user_id, u.user_email_id FROM tbl_user as u WHERE u.user_email_id = '".$user_email."'";
$result = @mysql_query($qry) or die("Couldn't execute query:".mysql_error().''.mysql_errno());
$rec = @mysql_fetch_row($result);
if($rec)
{
echo "Record exist";
}
else
{
echo "Record not exist";
}
}
注意:我只想列出表中不存在的记录。
请建议我解决这个...