Dan Shirah wrote:
UGH!
I am now constantly getting an error of "PHP Fatal error: Allowed memory
size of 16777216 bytes exhausted (tried to allocate 936 bytes) on line 689"
Is there a way to continuously write to the file and avoid getting this
error?
On 7/3/08, Dan Shirah <mrsquash2@xxxxxxxxx> wrote:
GOT IT!!!
I changed my code to the following:
$sql = "SELECT * FROM brev_pending_summary_detail WHERE name =
'$name_code'";
if (!empty($case_age)) {
$sql.=" AND case_age_group = '$case_age'";
}
if (!empty($case_cat)) {
$sql.=" AND case_category = '$case_cat'";
}
if (!empty($case_status)) {
$sql.=" AND case_status = '$case_status'";
} // Start our query of the database
$query = ifx_query($sql, $connect_id);
$row = ifx_fetch_row($query);
$results = array();
echo date('H:i:s') . " Add some data<br />\n";
for ($i = 3, $j = 0; $i <= $count; $i++, $j++) {
$results[$j] = ifx_fetch_row($query);
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i,
$results[$j]['stat_year']);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i,
$results[$j]['stat_month']);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i,
$results[$j]['name']);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i,
$results[$j]['case_age_group']);
}
I created a seperate query to get the row count...created an empty array (
$results = array(); )
I set $i = 3 so my results will start printing on line 3 of the spreadsheet
I set $j = 0 so the row data will start at the first row of the results
from my query
Then I made the loop repeat until $i became equal to the total number of
rows
And I then set the value of my previsouly empty array equal to the current
counted row of my query results
And to round it all off I echo'd out my results by using the new
$results($j) value appended with my database column names ['stat_year'] etc.
AWESOME! I hope someone else learns from this or can use this!
What is on and around line 689?
Unless you need the $results array later after the for loop you should
overwrite it each time, so use $results = ifx_fetch_row($query);
instead. Maybe this:
$i = 3;
while ($results = ifx_fetch_row($query)) {
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i,
$results['stat_year']);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $i,
$results['stat_month']);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $i,
$results['name']);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $i,
$results['case_age_group']);
$i++;
}
-Shawn
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php