#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    11
    Rep Power
    0
    Just a newbie question...

    How can I save the results of a command
    (i.e.: "DESCRIBE mytable;" ) to a file;

    thx in advance.
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?
    //not tested
    $result = mysql_query("describe table");
    $desc = mysql_result($result,0);

    $fp = fopen("filename.txt");
    fputs($fp,$desc);
    fclose($fp);
    ?>
    [/code]
    I think that'll work. I think describe table only returns one row.

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    11
    Rep Power
    0
    That's great, but (ooops..) I've forgot to say I need to do it from the console.
    (anyway thx for the suggestion)

    --------
    eep.
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    Do a dump from the command line, outside of mysql

    mysqldump -d -uuser -ppass database table > file.sql

    -d is for no data, just the table creation info. You can leave out 'table' and get the info for the whole database...

    Hope that helps...

    ---John Holmes...
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    11
    Rep Power
    0
    Exactly what I needed...

    Thx a lot.

    ---------
    eep.

Similar Threads

  1. Using sessions for search / results pages
    By Quirk in forum PHP Development
    Replies: 10
    Last Post: December 15th, 2003, 09:36 PM
  2. Limit results on 'left join' query
    By tippiedog in forum MySQL Help
    Replies: 1
    Last Post: November 12th, 2003, 08:58 AM
  3. Replies: 3
    Last Post: August 27th, 2003, 05:26 PM
  4. search results coming from multiple tables
    By frostfire in forum MySQL Help
    Replies: 0
    Last Post: August 12th, 2003, 10:23 AM
  5. Replies: 1
    Last Post: August 8th, 2003, 03:40 AM

IMN logo majestic logo threadwatch logo seochat tools logo