0

I was wondering if there is a way to get everything (all records) from a database? Then the user will have the option to save that file as an excel spreadsheet.

I was looking at DTS (data transformation service) is this the same thing?

Is there a specific query that can be sent through PHP to the database, would that be too much load on it?

I did some volume analysis and figured that the largest the database will ever get will be no more than 40mb.

So Ideally what I want to achieve is this.

  1. Query "get everything from database"
  2. My PHP "recieves query result"
  3. My PHP "transforms it into an excel file"
  4. Prompt user to save excel file

Is this possible?

Thanks

2
  • 'SELECT * FROM [tablename]' will get you number 1. Commented Aug 5, 2011 at 13:15
  • but what about all my tables, I have 20 tables? Commented Aug 5, 2011 at 13:17

3 Answers 3

3

You can only SELECT everything from a table; iterate a list of all tables (use SHOW TABLES of information_schema.tables) and run SELECT * FROM ... for each.

Sign up to request clarification or add additional context in comments.

1 Comment

Why is this the "only right answer"? MySQL can write a CSV file from a table directly, you don't have to select everything from each and write your own generator.
2

Databases are not spreadsheets. You can get a CSV representation of a single table containing no binary data (which Excel will open) using a SELECT ... INTO OUTFILE query.

http://dev.mysql.com/doc/refman/5.1/en/select.html

Comments

0
<?php
    $output = array();
    $tables = array('table1','table2','table3');
    foreach($tables as $table) {
        $sql = "SELECT * from " . $table;
        $result = mysql_query($sql);
        array_push($output, $result);
    }
    // You now have an array of database objects for each table 
    // to do with as you will.
?>

1 Comment

What does an array of result set resource pointers do for you?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.