php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49256 PHP ignores Where clause on Where with boolean fields
Submitted: 2009-08-14 16:07 UTC Modified: 2009-08-20 11:23 UTC
From: rafinguer at gmail dot com Assigned:
Status: Not a bug Package: PostgreSQL related
PHP Version: 5.2SVN-2009-08-14 (snap) OS: Windows Vista
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rafinguer at gmail dot com
New email:
PHP Version: OS:

 

 [2009-08-14 16:07 UTC] rafinguer at gmail dot com
Description:
------------
PHP ignores the true or false values in a SQL sentence, returning always  
all the records:

select id_product_type, name_product_type 
from sch_trazalogic.product_type 
where deleted=false
order by name_product_type

I tried with "where deleted='f'" and with "where not deleted". The 
result is the same. With PGAdmin (Query tool), the result is correct.

Reproduce code:
---------------
$result="";
$qry = "select id_product_type, name_product_type ".
       "from sch_trazalogic.product_type ".
       "where deleted=false ".
       "order by name_product_type";
$result_qry = pg_query($connection, $qry);
$num_rows = pg_numrows($result_qry);
$current=0;
while ($current<$num_rows) {
  $row = pg_fetch_row($result_qry, $current);  // fetch current row
  $result = $result_xml.$row[0]."-".$row[1]."\n";
  $current++;
}
pg_close($connection);
echo $result_xml;


Expected result:
----------------
All the records with "deleted" with "false" value

Actual result:
--------------
All the records (deleted=true and deleted=false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-15 09:25 UTC] rafinguer at yahoo dot es
I forgot to mention that the version of PostgreSQL is 8.3
 [2009-08-15 09:30 UTC] rafinguer at yahoo dot es
I'm sorry. The code is not correct. The code is the next following:

$result="";
$qry = "select id_product_type, name_product_type ".
       "from sch_trazalogic.product_type ".
       "where deleted=false ".
       "order by name_product_type";
$result_qry = pg_query($connection, $qry);
$num_rows = pg_numrows($result_qry);
$current=0;
while ($current<$num_rows) {
  $row = pg_fetch_row($result_qry, $current);  // fetch current row
  $result = $result.$row[0]."-".$row[1]."\n";
  $current++;
}
pg_close($connection);
echo $result;

Apache version is 2.2
 [2009-08-16 06:05 UTC] selotsom at hotmail dot com
I use postgre and php, and I have not any problem. I also use logical deletions with a boolean field, and it works well.

Please, send me your code and the database model at selotsom@hotmail.com
 [2009-08-20 11:23 UTC] jani@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC