#37124 [Opn->Fbk]: PostgreSQL Query Returns Resource id for Field Value
| From: | tony2001@php.net | Date: | Tue, 18 Apr 2006 17:57:30 +0000 |
| Subject: | #37124 [Opn->Fbk]: PostgreSQL Query Returns Resource id for Field Value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95942@lists.php.net to get a copy of this message | ||
ID: 37124
Updated by: tony2001@php.net
Reported By: ahaig at penguinmilitia dot net
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Mac OS X 10.4.6
PHP Version: 5.1.2
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
Previous Comments:
------------------------------------------------------------------------
[2006-04-18 17:54:08] ahaig at penguinmilitia dot net
Description:
------------
I'm using PostgreSQL 8.0.2
Query:
SELECT t.tgargs as args FROM pg_trigger t,pg_class c,pg_proc
p WHERE t.tgenabled AND t.tgrelid = c.oid AND t.tgfoid =
p.oid AND p.proname = 'RI_FKey_check_ins' AND c.relname
=:tablename ORDER BY t.tgrelid
:tablename is bound to a var with the value 'tables' (for my
particular case), and the same result occurs if I do not use
binding and fill the string in myself with 'tables' instead
of :tablename. When I run the query in psql it returns:
args
------------------------------------------------------------
tables_mainclassname_fkey\000tables\000classes
\000UNSPECIFIED\000mainclassname\000object_class\000
tables_databasehandle_fkey\000tables\000databases
\000UNSPECIFIED\000databasehandle\000databasehandle\000
(2 rows)
Reproduce code:
---------------
$statement = $my_PDO_instance->prepare("SELECT t.tgargs as args FROM
pg_trigger t,pg_class c,pg_proc p WHERE t.tgenabled AND t.tgrelid =
c.oid AND t.tgfoid = p.oid AND p.proname = 'RI_FKey_check_ins' AND
c.relname =:tablename ORDER BY t.tgrelid");
$statement->bindParam( ':tablename', $table );
$statement->execute();
print_r($statement->fetchAll());
The same thing occurs if I do:
foreach ( $my_PDO_instance->query("SELECT t.tgargs as args FROM
pg_trigger t,pg_class c,pg_proc p WHERE t.tgenabled AND t.tgrelid =
c.oid AND t.tgfoid = p.oid AND p.proname = 'RI_FKey_check_ins' AND
c.relname =:tablename ORDER BY t.tgrelid") as $this_row ) {
print_r($this_row);
}
Expected result:
----------------
Array ( [args] => tables_mainclassname_fkey\000tables
\000classes\000UNSPECIFIED\000mainclassname\000object_class
\000 ) Array ( [args] => tables_databasehandle_fkey\000tables
\000databases\000UNSPECIFIED\000databasehandle
\000databasehandle\000 )
Actual result:
--------------
Array ( [args] => Resource id #20 ) Array ( [args] => Resource
id #21 )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37124&edit=1