|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 01:00:02 2025 UTC |
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