From: ernesto_sanz at hotmail dot com Operating system: Ubuntu 7.04 PHP version: 5.2.6 PHP Bug Type: PostgreSQL related Bug description: Boolean variables returned by pg_fetch_array
Description: ------------ I'm using Ubuntu Feisty Fawn 7.04 with Apache with PHP 5.2.4 and Postgres v.8.2.4. I have noticed that, when querys are run, logical variables are not correctly assigned. E.g. being 'lists' the table defined by the SQL sentence: CREATE TABLE lists ( active boolean NOT NULL DEFAULT true, reference serial NOT NULL, caducated boolean NOT NULL DEFAULT false, name character varying(100) NOT NULL, ... ) and the PHP code // creation of the SQL sentence $consulta="SELECT * FROM lists WHERE ((referencie=".$mykey.") AND (active=true))"; // Execution $result = pg_query($consulta) or die('Error in SQL query:'.pg_last_error()); if (pg_num_rows($resultado)>0) { { $line = pg_fetch_array($result, null, PGSQL_ASSOC); if ($line["caducated"]==true) { ... -code executed if condition=true- } else { ... -code executed if condition=false- } ... I realized that the 'else' code was executed ALWAYS. It did not matter if the condition was $line["caducated"]==True, or TRUE, or 1, or False or FALSE or 0. I noticed that logical variables are assigned to 't' or 'f' instead of 'true' or 'false' (or numbers) (although their type -boolean- is correct- and, that the only way to execute correctly the 'if' sentence is by typing "if ($line["caducated"]==t)" (or "$line["caducated"]==f") which violates the reference syntax of PHP, that states that to specify a boolean literal we have to use keywords TRUE or FALSE (both case-insensitive). -- Edit bug report at http://bugs.php.net/?id=45152&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45152&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45152&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45152&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45152&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45152&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45152&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45152&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45152&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45152&r=support Expected behavior: http://bugs.php.net/fix.php?id=45152&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45152&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45152&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45152&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45152&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45152&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45152&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45152&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45152&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45152&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45152&r=mysqlcfg