Hi
Is it possible? If it is how to do it?
Example:
Query = SELECT em_login, em_name FROM employee
And table employee has no records.
So how to get column names: em_login, em_name?
Thx 4 ur help
Martin
How to get fields list of ANY query that returns no records
Moderator: General Moderators
-
martinwronski
- Forum Newbie
- Posts: 4
- Joined: Mon Jul 31, 2006 2:15 pm
-
martinwronski
- Forum Newbie
- Posts: 4
- Joined: Mon Jul 31, 2006 2:15 pm
thx, I know that
But I want to read that info from ANY query with multiple joins, subqueries, group by’s etc
is it possible?
psql returns column names event if there is no data returned but how to do this in php?
or how about this
SELECT em_login, em_salary * 12 AS year_salary FROM employee
how to find out that this query returns em_login/year_salary fields?
But I want to read that info from ANY query with multiple joins, subqueries, group by’s etc
is it possible?
psql returns column names event if there is no data returned but how to do this in php?
or how about this
SELECT em_login, em_salary * 12 AS year_salary FROM employee
how to find out that this query returns em_login/year_salary fields?
-
martinwronski
- Forum Newbie
- Posts: 4
- Joined: Mon Jul 31, 2006 2:15 pm
I have just found one way to do it by calling psql as an external program:
e.g.
exec("psql -h host -d database -U user -o \"$sFile\" -c \"$sQuery\"");
I have to generete psql results to file coz if I run psql with no -o switch it throws an exceptoion (under win2k).
also i have to remove all EOL to make it works fine:
$sQuery = str_replace("\n", ' ', $sQuery);
if anyone know the better way to do it please post it.
e.g.
exec("psql -h host -d database -U user -o \"$sFile\" -c \"$sQuery\"");
I have to generete psql results to file coz if I run psql with no -o switch it throws an exceptoion (under win2k).
also i have to remove all EOL to make it works fine:
$sQuery = str_replace("\n", ' ', $sQuery);
if anyone know the better way to do it please post it.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
psst, postgres..volka wrote:See http://de2.php.net/mysql_num_fields and http://de2.php.net/mysql_field_name
-
martinwronski
- Forum Newbie
- Posts: 4
- Joined: Mon Jul 31, 2006 2:15 pm