php - Export mysql database using OUTFILE command into .sql format -
here want export database .sql format.i tried select * outfile --- --- command returns records not whole structure of table. code is
<?php //include("db.php"); $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('could not connect: ' . mysql_error()); } mysql_select_db('ganga_hms'); $table_name = "accountant"; $backup_file = "c:/xampp/htdocs/finalhms/accountant.sql"; $sql = "select * outfile '$backup_file' $table_name"; $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('could not take data backup: ' . mysql_error()); } echo "backedup data successfully\n"; mysql_close($conn); ?> however want export table structure. , suggest me how export whole database using php.
to dump database need "mysqldump" tool, if not have tool on server , can not install it, you'll need complex script runs on of tables , gathers table structure , data this: http://davidwalsh.name/backup-mysql-database-php
Comments
Post a Comment