We have backups of our websites, but I would like to be able to click a button in our own CMS that saves either some fundamental tables, or ALL tables. So it basically does what the phpmyadmin 'export' to .sql does.
How does one go about that?
How do I run a 'save as' script to export database?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
How do I run a 'save as' script to export database?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do I run a 'save as' script to export database?
You can't stick with mysqldump at the command line? Or a manual export when you need one?
phpMyAdmin is written in PHP. Have you taken a look at how they do it?
Code: Select all
So it basically does what the phpmyadmin 'export' to .sql does.-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do I run a 'save as' script to export database?
I can login to the control panel system, and go thru the various buttons to get there - but we regularly work in the CMS for the website so I wondered if I could do it from there instead.
I don't quite know where in phpmyadmin that code would be. But I figured there would be an easy way to do it anyway.
I don't quite know where in phpmyadmin that code would be. But I figured there would be an easy way to do it anyway.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do I run a 'save as' script to export database?
You basically need the schema definitions, SELECT * from each table, and write to file. What have you tried so far?
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do I run a 'save as' script to export database?
I Tried this simple query:
Code: Select all
<?php
include "dbconn.php";
mysql_query("SELECT * FROM products INTO OUTFILE '/tmp/products.sql'");
echo "yes";
?>Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.