Hi,
It is like continue getting data from mysql using PHP and simultaneously stream out to the http.
Like in java we can write into ServletOutput stream?
The size of the data can be like 200 MB.
Thanks
Hi,
It is like continue getting data from mysql using PHP and simultaneously stream out to the http.
Like in java we can write into ServletOutput stream?
The size of the data can be like 200 MB.
Thanks
It sounds like you need PHP or some equivalent... Can you be more specific as to what you are trying to do?
I think you are looking to flush the output buffer in PHP. For more information see the flush function and the other output control functions in the PHP manual.
Here's a script that executes several select statements on a table and writes each result row to the output stream. It really does no differently than echoing, but maybe you can adapt it, e.g., by using a different stream wrapper (predefined or custom). Add security and error-checking code, of course.
Supposing a table containing fields "name" and "home_country".
$dsn = 'mysql:host=localhost;dbname=test';
$uname = 'uname';
$pword = 'password';
$countries = array('Mexico', 'Egypt', 'Estonia', 'Australia');
$pdo = new PDO($dsn, $uname, $pword);
$qry_stmnt = 'SELECT name, home_country
FROM places_test
WHERE home_country = :country';
$stmnt = $pdo->prepare($qry_stmnt);
$out_stream = fopen('php://output', 'w');
foreach ($countries as $country) {
$result = $stmnt->execute(array(':country' => $country));
$obj = $stmnt->fetchAll(PDO::FETCH_OBJ);
foreach ($obj as $row) {
fwrite($out_stream, $row->name . ': ' . $row->home_country . '<br />');
}
}
fclose($out_stream);