|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-12 16:49 UTC] nospam at unclassified dot de
[2011-11-12 16:49 UTC] nospam at unclassified dot de
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jan 05 02:00:02 2026 UTC |
Description: ------------ An SQL query in PDO and SQLite which has a bound parameter in the having clause will return no result. If that parameter is inserted in the SQL string, the query works fine. There is no URL to watch the bug, so here's my code: Test script: --------------- --- SQL setup: create table things (name); insert into things values ('car'); insert into things values ('car'); insert into things values ('car'); insert into things values ('car'); insert into things values ('car'); insert into things values ('car'); insert into things values ('bus'); insert into things values ('bus'); insert into things values ('bus'); insert into things values ('bus'); insert into things values ('bus'); insert into things values ('train'); insert into things values ('train'); insert into things values ('train'); insert into things values ('train'); insert into things values ('train'); insert into things values ('airplane'); insert into things values ('tree'); insert into things values ('tree'); insert into things values ('chair'); insert into things values ('chair'); insert into things values ('chair'); --- PHP code: <?php $sql = 'select name, count(*) cnt from things group by name having cnt >= ? order by cnt desc'; $params = array(3); $pdo = new PDO('sqlite:havingtest.db'); $ps = $pdo->prepare($sql); $r = $ps->execute($params); $records = $ps->fetchAll(PDO::FETCH_ASSOC); header('Content-type: text/plain'); var_dump($records); ?> Expected result: ---------------- array(4) { [0]=> array(2) { ["name"]=> string(3) "car" ["cnt"]=> string(1) "6" } [1]=> array(2) { ["name"]=> string(3) "bus" ["cnt"]=> string(1) "5" } [2]=> array(2) { ["name"]=> string(5) "train" ["cnt"]=> string(1) "5" } [3]=> array(2) { ["name"]=> string(5) "chair" ["cnt"]=> string(1) "3" } } Actual result: -------------- array(0) { }