Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
But how to get the fieldnames from PHP commands?
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly 6 4706
* Miles Keaton <mi*********@gm ail.com> [2004-10-25 19:36:43 -0700]: Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
But how to get the fieldnames from PHP commands?
If your namespace is 'public' and your table is 'users', for example:
SELECT attname
FROM pg_namespace, pg_attribute, pg_type, pg_class
WHERE pg_type.oid = atttypid
AND pg_class.oid = attrelid
AND pg_namespace.ns pname = 'public'
AND relnamespace = pg_namespace.oi d
AND relname = 'users'
AND attnum >= 1;
--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
On Mon, Oct 25, 2004 at 07:36:43PM -0700, Miles Keaton wrote: Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
If you run "psql -E" or type "\set ECHO_HIDDEN" after you're
in psql then you'll see the hidden queries that psql sends for
"\d tablename", etc. Examine those queries and use the relevant
parts in your own code.
You might want to familiarize yourself with the system catalogs,
which is what you'll be querying: http://www.postgresql.org/docs/7.4/static/catalogs.html
--
Michael Fuhr http://www.fuhr.org/~mfuhr/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Miles Keaton wrote: Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
But how to get the fieldnames from PHP commands?
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to ma*******@postg resql.org so that your message can get through to the mailing list cleanly
If you have a look at the PHP manual there is a function to do this for
you - pg_meta_data - check out the manual...
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
On Mon, 2004-10-25 at 20:36, Miles Keaton wrote: Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
But how to get the fieldnames from PHP commands?
In addition to the other ideas given here, you also have the SQL spec
standard information_sch ema to examine
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly
Scott Marlowe wrote: On Mon, 2004-10-25 at 20:36, Miles Keaton wrote:
Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
But how to get the fieldnames from PHP commands?
Hello,
This PHP function will give you what you need: http://us2.php.net/manual/en/print/f...field-name.php
Sincerely,
Joshua D. Drake In addition to the other ideas given here, you also have the SQL spec standard information_sch ema to examine
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to ma*******@postg resql.org so that your message can get through to the mailing list cleanly
--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandpromp t.com - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL
Miles Keaton wrote: Is there a simple way to list fieldnames in a table, from PHP?
When on the command-line, I just do \d tablename
But how to get the fieldnames from PHP commands?
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to ma*******@postg resql.org so that your message can get through to the mailing list cleanly
Here is one way Python can do it through ODBC:
# fetch descriptions to create field name dictionaries
try:
ci = db.cursor()
ci.execute("sel ect * from PERSINFO where 1 = 0")
column = 0
for d in ci.description: # key : value
PersFields[d[0]] = column # field name : position
PersPos[column] = d[0] # position : field name d[0]
PersTypes[d[0]] = d[1] # field name : data type d[1]
PersPrec[d[0]] = d[4] # field name : precision d[4]
PersScale[d[0]] = d[5] # field name : scale d[5]
PersVals[column] = None # position : value (init=None)
column += 1
ci.close()
ci = None
--
--
GreyGeek This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sam |
last post by:
I have a function writen in Perl that takes a name-value list (array) as
argument
and returns a name-value list (array).
My question is:
How to call this function from PHP and get the returned name-value list in
PHP variable?
Thanks.
|
by: steve |
last post by:
I have an on-going problem that my ".MYI" mysql files get corrupted.
I have written php trapping routine to report on the problem to
admin. My next step is to initiate "repair table" right after the
error is trapped.
The problem is that then I would have multiple repair table commands
initiated from different browser sessions. How can I make sure that
only one "repair table" is running at a time.
--
|
by: alex |
last post by:
Hi,
I am looking for a way to populate an HTML table from an external
local text file which looks like this:
DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
|
by: mh |
last post by:
Hello,
I'm trying to create a table from a PHP script.
>From what I read in my book about PHP and MySQL I
should do something like that:
$sql_query="CREATE TABLE '$num' (
'variable1' mediumint(6) unsigned NOT
NULL,
|
by: nescio |
last post by:
hello,
i have made an application in php so that people can make, on the fly, a
form.
when they submit the form there is a javascript formvalidation.
because we do not know how many fields there are in the form (it is made on
the fly) i collect all the form fieldnames in an php array and sent it to
the javascript function:
| |
by: Lorenzo Thurman |
last post by:
I'm connecting to an access database and I would like the query to
return results grouped on a particular column. When I try the following
query, I get this error back from PHP:
DB Error: syntax Error
"SELECT * FROM HardwareInstallationsSummary WHERE LocationID = $loc_ID
GROUP BY Manufacturer"
Iposted this question on a PHP list and someone there suggested that SQl
does not allow this to happen unless its part of an aggregate...
|
by: jamie |
last post by:
I am trying to populate a mysql table from the contents of a <SELECT>
list using PHP. The list is populated from another list and from
there
all the items need to be saved to a table.
|
by: abbeyro |
last post by:
Hello,
I'm trying to retrieve a list of tables from all_tables in a given
Oracle db. I'm using System.Data.OracleClient, OracleCommand and
OracleDataReader and I always obtain the results in uppercase. The
problem is that some tables where defined in "Mixed/Case" so when I
retrieve the list I need to obtain the exact case used when they were
created. Is there any option I need to specify in the connection or
the data provider to achieve...
|
by: trpost |
last post by:
I am looking for a way to send data from one page to another as POST
data without using forms or cURL.
I have a php script that is passing a list of cases from on page to
another when a link is clicked. This is working fine for the most part
as a link, but sometimes the list gets very large and gets cut off.
The reason it gets cut off appears to be a limitation on the amount of
data that can be passesd in the URI.
It looks like I can...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |