Re: MySQL Dump using PHP

From: Date: Sun, 07 Dec 2003 12:56:44 +0000
Subject: Re: MySQL Dump using PHP
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-172128@lists.php.net to get a copy of this message
"Justin Patrin" <papercrane@reversefold.com> wrote news:20031206212206.79564.qmail@pb1.pair.com... > Use mysqldump in a system() call, redirect it to a temp file, then read > it back and out to the browser. > > Or, you could use popen to get the output piped back into php. Make sure > to check the mysqldump options for things you need (I often use -Q -e > --add-drop-table). > > <?php > header('Content-type: application/mysql'); > header('Content-disposition: attachment; filename=dump.sql'); > $fd = popen('mysqldump -uuser -ppassword databaseName', 'r'); > while(!feof($fd)) { > echo fgets($fd); > } > pclose($fd); > ?> Thanks a lot. I haven't used this functions ever, but I'm sure PHP.net (and maybe some help from you guys) will do the job. Also thanks to Ajai for the idea. ___________________________ Cesar L. Aracena Commercial Manager / Developer ICAAM Web Solutions 2K GROUP Neuquen, Argentina Tel: +54.299.4774532 Cel: +54.299.6356688 E-mail: lists@icaam.com.ar

« previous php.general (#172128) next »