What is the best way to generate & print out data from mysql database
Le开发者_StackOverflow社区t's say I want print out 1 mil user record from database to paper.
The output format will be something like this.
No Name Address Phone Class Teacher
----------------------------------------------------
1 John 123-etc 3214124 5 Miku
2 L.Gaga 123-etc 3214124 9 Koru
..
..
..
..
10000000 Puke 123123 3214124 2 Goku
What is the best method to print out this data without adding any limit to mysql query?
What I normally do in such a case, is using a tool like Navicat to write a query that gives me exactly the columns I need, ordered in the way I need them, and then use the export function of the tool to save the result in an Excel file.
That way I get all the Excel (or OpenOffice, for that matter) options for printing, including scaling to get as much records on one page as possible.
You could query as normal and use PHP to write the results to a CSV file for further formatting, printing, etc. http://php.net/manual/en/function.fputcsv.php
I don't think 1 million rows will be too much, but it will depend on your hardware (memory), environment (php timeouts), and the actual data. The paper itself might be a problem, though.
精彩评论