[PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Jay Blanchard

Howdy group!

I am outputting a rather large data set to an Excel spreadsheet from a MySQL
database on a healthy FreeBSD server. The Apache server is on the same
server as the database. The code looks like this

?
/*
** SWB CABS Project
** USOC Charges Detail
** Report By Criteria - Spreadsheet
*/

// open output buffer
ob_start();

// excel headers
header(Content-Type:  application/vnd.ms-excel);
header(Content-Disposition: inline; filename=\excel.xls\);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);


/*
** lots of code that gets roughly
** 15,000 - 20,000 rows of data
** each row is 209 bytes of data
*/


// close output buffer
ob_end_flush();
?

Now, even though I have set ob_start() the headers get sent (as it says in
the docs; While output buffering is active no output is sent from the
script (other than headers), instead the output is stored in an internal
buffer. )

The Task Manager shows that the processes on my local machine for EXCEL.EXE
go to the maximum available CPU cycles and stays there until the spreadsheet
is either delivered or the system times out. I thought that using output
buffering would lower use of client system resources. Is this not true?

Thanks!

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Kevin Stone

Output buffering is doing nothing for you in the given example.  It does not
reduce client side resources... if anything it increases the usage
serverside resources.  Perhaps you are thinking of gz compression?  You
might use a combination of ob* functions and gz* functions to minimize
bandwidth requirments.. but there's no guarantee that your user's browsers
supports it.

http://www.php.net/manual/en/printwn/function.gzcompress.php

-Kevin

- Original Message -
From: Jay Blanchard [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 25, 2002 10:45 AM
Subject: [PHP] Output Buffering - Am I using it correctly?


 Howdy group!

 I am outputting a rather large data set to an Excel spreadsheet from a
MySQL
 database on a healthy FreeBSD server. The Apache server is on the same
 server as the database. The code looks like this

 ?
 /*
 ** SWB CABS Project
 ** USOC Charges Detail
 ** Report By Criteria - Spreadsheet
 */

 // open output buffer
 ob_start();

 // excel headers
 header(Content-Type:  application/vnd.ms-excel);
 header(Content-Disposition: inline; filename=\excel.xls\);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);

 
 /*
 ** lots of code that gets roughly
 ** 15,000 - 20,000 rows of data
 ** each row is 209 bytes of data
 */
 

 // close output buffer
 ob_end_flush();
 ?

 Now, even though I have set ob_start() the headers get sent (as it says in
 the docs; While output buffering is active no output is sent from the
 script (other than headers), instead the output is stored in an internal
 buffer. )

 The Task Manager shows that the processes on my local machine for
EXCEL.EXE
 go to the maximum available CPU cycles and stays there until the
spreadsheet
 is either delivered or the system times out. I thought that using output
 buffering would lower use of client system resources. Is this not true?

 Thanks!

 Jay



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Jay Blanchard

[snip]
Output buffering is doing nothing for you in the given example.  It does not
reduce client side resources... if anything it increases the usage
serverside resources.  Perhaps you are thinking of gz compression?  You
might use a combination of ob* functions and gz* functions to minimize
bandwidth requirments.. but there's no guarantee that your user's browsers
supports it.
[/snip]

Fatal error: Call to undefined function: gzcompress() in
/var/lib/apache/htdocs/swbcabs/gen.php on line 89

I guess that this means I am out of luck here. Anyone know a cleaner method
for delivering spreadsheets?

Thanks!

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Beau Hartshorne

 I guess that this means I am out of luck here. Anyone know a cleaner 
 method for delivering spreadsheets?

Can you get the server to write it to a file, and then let the client
download the file normally?

Beau



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Jay Blanchard

[snip]
 I guess that this means I am out of luck here. Anyone know a cleaner
 method for delivering spreadsheets?

Can you get the server to write it to a file, and then let the client
download the file normally?
[/snip]

Believe me, if I could have taken that way out I would have done it. I am
researching some classes, but they all seem to take just as long to create
the spreadsheet.

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Jay Blanchard

[snip]
 I am researching some classes 
[/snip]

OK. One of the silly classes fails, saying --

Fatal error: No parent class available in this context in biff.php on line
52

line 52 is --

49 function BiffWriter()
50  {
51  error_reporting (E_ALL);
52  parent::BiffBase();
53  $this-_fill_AA_notation();
54  }

This is on a server with PHP 4.04. Does anyone have any clues as to why it
might not work?
ACCCK! I am so frustrated at this point that I would almost rather write
spreadsheets by hand!

Thanks for your help!

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Beau Hartshorne

 Can you get the server to write it to a file, and then let the client
 download the file normally?
 [/snip]
 
 Believe me, if I could have taken that way out I would have done it. I
am
 researching some classes, but they all seem to take just as long to
create
 the spreadsheet.

What about something like this:

1. Script loads. Script writes everything to some file.
2. Script is finished writing everything to file.
4. Script does a browser redirect and the user starts downloading the
file normally.

It just seems like the server doesn't want to have to deal with
streaming a large database result set to a web browser.

Beau



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Output Buffering - Am I using it correctly?

2002-09-25 Thread Jay Blanchard

[snip]
OK. One of the silly classes fails, saying --

Fatal error: No parent class available in this context in biff.php on line
52

line 52 is --

49 function BiffWriter()
50  {
51  error_reporting (E_ALL);
52  parent::BiffBase();
53  $this-_fill_AA_notation();
54  }

This is on a server with PHP 4.04. Does anyone have any clues as to why it
might not work?
[/snip]

I actually identified this in the above post without realizing it. The 4.04
version of PHP does not support the parent:: directive. Ah well, looks like
we're going to have to clear some time for an upgrade.

Thanks!

Jay



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php