我有一个php网页,它从我的MSSQL DB中提取数据并将其打印到csv文件。对于我的所有其他页面,这工作正常。然后我到达了一个结果集近40000的那个。我知道那不是那么大,但它似乎并没有起作用。这就是我的目标:
点击export to excel
按钮:
echo "<form action='ExportToExcel.php' method='POST'>";
echo "<div class='CenterStuff'>";
echo "<input type='hidden' name='ExportToExcel' value='MatTrackingAll'/>";
echo "<input type='hidden' name='Limit' value='$limit'/>";
echo "<input type='hidden' name='Offset' value='$offset'/>";
echo "<input type='submit' class='button' value='Export To Excel'>";
echo "</div></form>";
导出到Excel:我在调用此页面时设置了$limit
和$Offset
,但更改了它以尝试查找正在发生的事情。
$offset = 0;//$_POST['Offset'];
$limit = 27250;//$_POST['Limit'];
$tsql = "Select Id,State,ProjectNumber,SubProjectNumber,PONumber,POLineNumber,IMLineNumber,CalloutDetails,POStatus,BlanketRelease
,PODateIssued,DateNeeded,POINvoiceStatus,ItemCode,ItemDesc,QuantityOrdered,QuantityReceived,DateReceived,RecordStatus
,ShipToLocation,DeliverToLocation,ReceiverId,TraceNumber,BOL,PackSlipNumber,POTotalAmount,POLineAmount,CostCode,RequisitionId
,RequisitionLineNumber,Vendor,ExchangeName,ProjectType,COECurrentProjectStatus,ReadyForService,ScheduledShipDate,MaterialComments
,SchedulerComments,MaterialSpecialist
from pmdb.MaterialTracking order by State,ProjectNumber OFFSET $offset ROWS FETCH NEXT $limit ROWS ONLY";
$hsql = "select Headings from TableHeadings where TableName = 'MaterialTracking' and Headings != 'Edit' order by ID";
$getqueries = $conn->query($tsql);
$result = $getqueries->fetchALL(PDO::FETCH_ASSOC);
$filename = $_POST['ExportToExcel'];
然后我有我打印到csv的部分。我在那里有一些var_dump
,以便我可以看到保持的位置。当我以超过27250的限制运行时,我得到一个空白屏幕,没有任何反应。它不下载文件。我知道这个查询很好,但它在我打印过的$result = $getqueries->fetchALL(PDO::FETCH_ASSOC);' and the
var_dump and
echo之后就停止了。