Re: Loading SQL files (not CSV) into mySQL

From: Date: Tue, 03 Apr 2001 23:44:01 +0000
Subject: Re: Loading SQL files (not CSV) into mySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-46917@lists.php.net to get a copy of this message
I think you want: exec("/path/to/mysql -p$password -u$username $database < $filename"); On Wed, 04 Apr 2001 00:35:34 +0100, Andy Warwick (andy.war@ntlworld.com) wrote: >I'm after some pointers on how to dump and load SQL files to and >from mySQL >using a PHP/HTML form. > >I've read the manual about "LOAD DATA INFILE", but as far as I can >tell that >won't help in this case. Unfortunately, CSV files are not an option >(client's demands... go figure). > >What I'm after is dumping/uploading SQL files of the form: > >========================================================== ># ># PHP/MySQL Demo - Table Dump ># -------------------------------------------------------- > ># ># Structure ># > >DROP TABLE IF EXISTS demo; >CREATE TABLE demo ( > id tinyint(2) unsigned zerofill NOT NULL auto_increment, > name char(50) NOT NULL, > logo_url char(50) NOT NULL, > page_colour char(6) DEFAULT 'FFFFFF' NOT NULL, > last_order datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, > PRIMARY KEY (id), > KEY id (id), > UNIQUE id_2 (id) >); > ># ># Data ># > >INSERT INTO demo (id, name, logo_url, page_colour, last_order) >VALUES ( >'01', 'CompanyName', 'logo.gif', '99CCFF', >'2001-04-06 13:21:31'); >========================================================== > >Complete with table creation and data inserts. In effect, it needs >to be >standalone text files full of SQL commands. > >I know it can be done, because phpMyAdmin has exactly this facility. >But >even after studying the code of that carefully, I can't tell which >specific >pieces are handling this enough to extract the facility. > >Can anyone point me, or is willing to donate, any articles/code >snippets/etc >that will help. > >TIA > >Andy Warwick > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list- >admin@lists.php.net

« previous php.general (#46917) next »