我有我寫了下面的腳本:PHP腳本只能插入5000行到phpMyAdmin的數據庫
<?php
$filename = "readingDataFromThis.LOG";
$filterarray= array("stuff to remove from the file", "and more stuff");
if (file_exists($filename) && is_readable ($filename)) {
ini_set('memory_limit','16M');
ini_set('max_execution_time', 600);
$con=mysqli_connect("server","username","password","database_name");
$count = 0;
$fh = fopen($filename, "r");
if ($fh) {
while (($line = fgets($fh)) != false) {
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (strpos_arr($line, $filterarray) == false) {
$month = substr($line, 3,5);
$day = substr($line, 0,2);
$year = substr($line, 6,8);
$timestamp = substr($line, 9, 17);
$message = substr($line, 18);
mysqli_query($con,"INSERT INTO Conversation (Month, Day, Year, Time, Message)
VALUES ('$month', '$day', '$year', '$timestamp', '$message')");
echo "Inserted record " . $count++ . "<br>";
}
}
}
fclose($fh);
mysqli_close($con);
echo "Complete.";
}
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}
?>
當我運行它,我沒有問題,我收到了屏幕上的輸出基本上是這樣的:
Inserted record 0
Inserted record 1
...
Inserted record 14000+
Complete.
但是,當我到數據庫本身的表中時,我發現只有前5000條記錄才被插入到數據庫中。這裏發生了什麼?
'phpMyAdmin'對它一次顯示的行數有限制。你確定這不是你遇到的? 'SELECT COUNT(*)FROM Conversation'顯示什麼? – Barmar 2014-08-28 03:58:06
SELECT COUNT(*)FROM 通話 >返回> COUNT(*) ----所以,我手動插入一條記錄,我可以從我的主表視圖中看到5001分的記錄。 – cuckoo 2014-08-28 04:03:15
是否有任何列具有唯一索引?您可能有重複的內容。 – Barmar 2014-08-28 04:06:43