Re: Fw: Creating tables on the fly

From: Date: Wed, 06 Dec 2000 13:33:44 +0000
Subject: Re: Fw: Creating tables on the fly
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-5066@lists.php.net to get a copy of this message
Use mySQL's "describe table" ability. It'll give you a result array which'll have the column name, and it's type. =) Armed with that information, you can then do you conversion. I used that functionality to write a "wrapper generator" which outputs some PHP classes, 1 per table and generic INSERT/UPDATE/LOAD statements. *grin* 'Luck! -Szii ----- Original Message ----- From: Fábio Ottolini <fabio.ottolini@uol.com.br> To: db php <php-db@lists.php.net> Sent: Wednesday, December 06, 2000 5:18 PM Subject: Re: [PHP-DB] Fw: Creating tables on the fly > Thanks, Doug! You answers always help me a lot! In fact in this case it > really doesn't matter the MySQL sintax. I was just a little bit confused > about how to proceed when my SysAdmin acts like a mule! You gave the lights > and that's exactly what I needed. > > Kind regards, > > Fábio Ottolini > > ----- Original Message ----- > From: "Doug Semig" <dougslist@semig.com> > To: <php-db@lists.php.net> > Sent: Wednesday, December 06, 2000 1:30 AM > Subject: Re: [PHP-DB] Fw: Creating tables on the fly > > > > That's a tough one, Fábio. Maybe there's a MySQL specific mailing list? > > > > As it stands, having not worked much with MySQL, I can only think of three > > ways. None of them are optimal like "CREATE TABLE ... FROM SELECT ..." > > would be. > > > > 1. Know the schema beforehand and hard-code it in your app. > > > > 2. Discover the schema by selecting out a row and iterating through the > > fields with mysql_fetch_field() function and build the CREATE TABLE > statement. > > > > 3. There's a web application written in PHP that is for administration of > > MySQL installations. PHPMySQLAdmin or something like that (check > > www.freshmeat.net). There may be some clues in there! That is, if it > > works with pre-3.23 versions of MySQL, they had to figure out how to find > > out the structure of a MySQL table for that app. > > > > Oh, I suppose there's one more thing I can think of, but unfortunately it > > only has a small chance of working right away...beg your sysadmin to > > upgrade <grin>! > > > > Good luck, > > Doug > > > > At 05:29 PM 12/5/00 -0200, Fábio Ottolini wrote: > > >Hello!!! > > > > > >Please don't forget me... Could you please give me some insight about my > > >approach to this problem? > > > > > >Kind regards, > > > > > >Fábio Ottolini > > > > > >----- Original Message ----- > > >From: "Fábio Ottolini" <fabio.ottolini@uol.com.br> > > >To: "db php" <php-db@lists.php.net> > > >Sent: Monday, December 04, 2000 4:58 PM > > >Subject: Creating tables on the fly > > > > > > > > >> Dear All, > > >> > > >> At home I have MySQL 3.23.27 but at the server I will host my > application > > >> the have version MySQL 3.22.19. This means that I cannot use a query > like > > >> "CREATE TABLE $tblname SELECT * FROM $tblname_ant;", because as far as > I > > >> know this was implemented just after version 3.23.* and MySQL running > on > > >the > > >> host server is returning and error message anyway. Which is the best > way > > >to > > >> create a new table on the fly using another one as a model with this > > >> restriction? > > >> > > >> Best regards, > > >> > > >> Fábio Ottolini > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#5066) next »