note 90912 added to function.pg-field-table
| From: | strata_ranger at hotmail dot com | Date: | Sat, 16 May 2009 06:11:47 +0000 |
| Subject: | note 90912 added to function.pg-field-table | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154651@lists.php.net to get a copy of this message | ||
pg_field_table is primarily useful for queries that involve joins between multiple tables, e.g:
<?php
$res = pg_query("SELECT table1.foo, table2.bar FROM table1 JOIN table2");
echo pg_field_table($res, 0); // Outputs 'table1'
echo pg_field_table($res, 1); // Outputs 'table2'
?>
However, be aware of a few easy 'gotchas':
1- If your query contains static values in its select-list, pg_field_table() will yield FALSE for
those fields (because it was a static value, not one fetched from a table):
<?php
$res = pg_query("SELECT 'foo', bar FROM table");
echo pg_field_table($res, 0); // FALSE
echo pg_field_table($res, 1); // Outputs 'table'
?>
2- If you UNION two queries together from different tables, pg_field_table() will return FALSE for
all fields:
<?php
$res = pg_query("(Select foo, bar from table1) UNION (Select foo, bar from table2)");
echo pg_field_table($res, 0); // FALSE
echo pg_field_table($res, 1); // FALSE
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.2.25.104
----
Manual Page -- http://www.php.net/manual/en/function.pg-field-table.php
Edit -- https://master.php.net/note/edit/90912
Del: integrated -- https://master.php.net/note/delete/90912/integrated
Del: useless -- https://master.php.net/note/delete/90912/useless
Del: bad code -- https://master.php.net/note/delete/90912/bad+code
Del: spam -- https://master.php.net/note/delete/90912/spam
Del: non-english -- https://master.php.net/note/delete/90912/non-english
Del: in docs -- https://master.php.net/note/delete/90912/in+docs
Del: other reasons-- https://master.php.net/note/delete/90912
Reject -- https://master.php.net/note/reject/90912
Search -- https://master.php.net/manage/user-notes.php