Thread: How to create a new Table in prostgresql from a Webinterface
Hello, Never I have done this before (no need) but now I nee to create a new table with some colums from a Webinterface and do not know how to do that. Please can anyone point me into the right direction ? Thanks, Greetings and nice Weekend Michelle -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/3/88452356 67100 Strasbourg/France IRC #Debian (irc.icq.com)
Attachment
On Sat, 2004-08-14 at 17:15 +0200, Michelle Konzack wrote: > Hello, > > Never I have done this before (no need) but now I nee to create a > new table with some colums from a Webinterface and do not know how > to do that. > > Please can anyone point me into the right direction ? Are you looking for something like this? I just knocked this out, so I'm sure ther are syntax errors and whatnot, but it should give you an idea. Oh, and are mime attachments considered OK on this list? If not, my apologies. -Steve
Attachment
Michelle Konzack wrote: > Hello, > > Never I have done this before (no need) but now I nee to create a > new table with some colums from a Webinterface and do not know how > to do that. You have to execute a query: pg_query(connection, "CREATE TABLE tablename (id serial, val int4...);"); > > Please can anyone point me into the right direction ? > > Thanks, Greetings > and nice Weekend > Michelle >
Am 2004-08-15 00:55:34, schrieb Raoul Buzziol: > Michelle Konzack wrote: > > > Hello, > > > > Never I have done this before (no need) but now I nee to create a > > new table with some colums from a Webinterface and do not know how > > to do that. > > You have to execute a query: > > pg_query(connection, "CREATE TABLE tablename (id serial, val int4...);"); :-/ I was looking for a php-Command or somthing like this to create the table but not thinking on a pg_query WHICH execute the command... Greetings Michelle -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSM LinuxMichi 0033/3/88452356 67100 Strasbourg/France IRC #Debian (irc.icq.com)
Attachment
On Mon, 2004-08-16 at 10:11, Michelle Konzack wrote: > Am 2004-08-15 00:55:34, schrieb Raoul Buzziol: > > Michelle Konzack wrote: > > > > > Hello, > > > > > > Never I have done this before (no need) but now I nee to create a > > > new table with some colums from a Webinterface and do not know how > > > to do that. > > > > You have to execute a query: > > > > pg_query(connection, "CREATE TABLE tablename (id serial, val int4...);"); > > :-/ > > I was looking for a php-Command or somthing like this to create the > table but not thinking on a pg_query WHICH execute the command... > Well, a CREATE TABLE is just another type of SQL Query that you can run. It's not a 'command' exactly..just a query. -Robby -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | robby@planetargon.com * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development ****************************************/
Attachment
On php.net, if you did a search for pg_ , you would have seen the PHP Function List ..... pg_close pg_connect pg_convert pg_copy_to pg_dbname pg_delete pg_get_pid pg_host pg_insert pg_lo_open pg_lo_read pg_lo_seek pg_ping pg_port pg_query pg_select pg_trace pg_tty pg_update preg_grep \\pb Michelle Konzack wrote: > Am 2004-08-15 00:55:34, schrieb Raoul Buzziol: > >>Michelle Konzack wrote: >> >> >>>Hello, >>> >>>Never I have done this before (no need) but now I nee to create a >>>new table with some colums from a Webinterface and do not know how >>>to do that. >> >>You have to execute a query: >> >>pg_query(connection, "CREATE TABLE tablename (id serial, val int4...);"); > > > :-/ > > I was looking for a php-Command or somthing like this to create the > table but not thinking on a pg_query WHICH execute the command... > > > Greetings > Michelle >
Just a followup question. I'm fairly new to using PHP and pg. Security wise how could I limit a request such as this? I'm assuming that if you have given a PHP user the ability to create tables, the user also has the ability to truncate and delete tables as well. > On php.net, if you did a search for pg_ , you would have seen the PHP > Function List ..... > > pg_close pg_connect pg_convert pg_copy_to > pg_dbname pg_delete pg_get_pid pg_host > pg_insert pg_lo_open pg_lo_read pg_lo_seek > pg_ping pg_port pg_query pg_select > pg_trace pg_tty pg_update preg_grep > > > \\pb > > Michelle Konzack wrote: > > Am 2004-08-15 00:55:34, schrieb Raoul Buzziol: > > > >>Michelle Konzack wrote: > >> > >> > >>>Hello, > >>> > >>>Never I have done this before (no need) but now I nee to create a > >>>new table with some colums from a Webinterface and do not know how > >>>to do that. > >> > >>You have to execute a query: > >> > >>pg_query(connection, "CREATE TABLE tablename (id serial, val int4...);"); > > > > > > :-/ > > > > I was looking for a php-Command or somthing like this to create the > > table but not thinking on a pg_query WHICH execute the command... > > > > > > Greetings > > Michelle > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings
>>pg_query(connection, "CREATE TABLE tablename (id serial, val int4...);"); > > > :-/ > > I was looking for a php-Command or somthing like this to create the > table but not thinking on a pg_query WHICH execute the command... There is no such command.
On Mon, 16 Aug 2004 19:41:17 -0500 "Todd Lewis" <lewis-todd@comcast.net> sat down, thought long and then wrote: > Just a followup question. > > I'm fairly new to using PHP and pg. Security wise how could I limit a request > such as this? I'm assuming that if you have given a PHP user the ability to > create tables, the user also has the ability to truncate and delete tables as > well. > A database user has not much in common with a PHP user (or a UNIX- or other system user). The tables will be created with the database user you have connected with (if you use authentication other than trust or ident, see pg_hba.conf for details). So if you create tables within PHP, you create them as the connecting database user, and of course the creator may destroy them as well. But if you have a database, in which the tables are owned by user A and you connect with user B, user B may create tables owned by himself, but usually may not drop tables owned by user A, if he has not explicitly been granted so. What I do is: I have a database, in which all tables are owned by user A (a superuser) and user B (the PHP connecting user) has the right to read, write, update the tables, so he can work with them. But user B is not able to drop a table of user A. User B, however, is allowed to create and drop his own tables, if he likes. If you connect every PHP user as a different database user, no database user is able (if not explicitly granted) to drop other users´ tables. If not granted so, he is not even able to touch them (he could see their existence, however). Regards, -- Frank Finner Memory follows memory, memory defeats memory; some things are banished only into the realms of our rich imaginings - but this does not mean that they do not or cannot or will not exist - they exist! They exist! (M. Moorcock, "The Revenge Of The Rose")