#45101 [NEW]: pg_send_query_params ORDER BY ignored

From: Date: Tue, 27 May 2008 04:47:21 +0000
Subject: #45101 [NEW]: pg_send_query_params ORDER BY ignored
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125288@lists.php.net to get a copy of this message
From: alan at fromorbit dot com Operating system: Linux 2.6.24.7 x64 PHP version: 5.2.6 PHP Bug Type: PostgreSQL related Bug description: pg_send_query_params ORDER BY ignored Description: ------------ Hi all, I've discovered that if you use pg_send_query_params() and try and include a parameter for an 'ORDER BY' for example it's completely ignored. I've looked at the pg_trace() output and it appears to be doing the right thing. All I can assume is that the parameter is being converted to a TRUE for an ORDER BY, and so the database happily accepts 'ORDER BY 1'. Reproduce code: --------------- #!/opt/php/bin/php <?php /* create table php_bug (id integer, name varchar(255)); insert into php_bug values (1, 'one'); insert into php_bug values (2, 'two'); insert into php_bug values (3, 'three'); insert into php_bug values (4, 'four'); insert into php_bug values (5, 'five'); */ $conn = pg_connect('host=localhost dbname=test port=5432 user=web'); $sql = 'SELECT * FROM php_bug WHERE name LIKE $1 ORDER BY $2'; $params = array('%o%', 'doesnt_exist_and_should_be_an_sql_error'); if (! pg_connection_busy($conn)) pg_send_query_params($conn, $sql, $params); $res = pg_get_result($conn); while($row = pg_fetch_assoc($res)) echo "{$row['id']} - {$row['name']}\n"; ?> Expected result: ---------------- An SQL error or an output that is ordered by the given parameter Actual result: -------------- 1 - one 2 - two 4 - four -- Edit bug report at http://bugs.php.net/?id=45101&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45101&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45101&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45101&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45101&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45101&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45101&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45101&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45101&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45101&r=support Expected behavior: http://bugs.php.net/fix.php?id=45101&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45101&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45101&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45101&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45101&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45101&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45101&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45101&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45101&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45101&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45101&r=mysqlcfg

« previous php.bugs (#125288) next »