php - PDO query went ok but no final result provided -


i have troubles retrieving data distant database. access pdo database ok, debug.print rowcount, returns several occurences, code seems stop when comes fetching

        $arr = $reponse->fetchall(pdo::fetch_assoc);         

here link see : http://bacly.fr/baclymphp/gettournois.php

i did ame thing db, same code-like feature, , it's giving me result

http://bacly.fr/todophp/www/php/gettodo.php

here code gettournois.php :

<?php require("config.php");      $query="select t1.tournois_id tournois_id,t1.tournois_title tournois_title, t1.tournois_date_debut tournois_date_debut, t1.tournois_date_fin tournois_date_fin, t1.tournois_date_limite tournois_date_limite, coalesce(t2.tournois_inscriptions,0) tournois_inscriptions, t1.tournois_description tournois_description,  t1.tournois_simple tournois_simple, t1.tournois_double tournois_double, t1.tournois_mixte tournois_mixte ";     $query.= " ";     $query.= " (select t.tournois_id tournois_id, t.tournois_title tournois_title, t.tournois_date_debut tournois_date_debut, t.tournois_date_fin tournois_date_fin, t.tournois_date_limite tournois_date_limite, t.tournois_description tournois_description, t.tournois_simple tournois_simple, t.tournois_double tournois_double, t.tournois_mixte tournois_mixte jnew_tournois_tournois t";     $query.=" order tournois_date_limite desc) t1";     $query.= " left join";     $query.= " (select count(ti.tournois_inscriptions_id) tournois_inscriptions,ti.tournois_inscriptions_tid tournois_id jnew_tournois_tournois_inscriptions  ti) t2";     $query.= " on t1.tournois_id = t2.tournois_id order t1.tournois_date_limite desc";      debug.print($query);      try     {         $bdd = new pdo($db_config['sgbd'] .':host='. $db_config['host'] .';dbname='. $db_config['db_name'], $db_config['user'], $db_config['password'], $db_config['options']);         $reponse = $bdd->prepare($query);         $reponse->execute();         debug.print("rowcount");         debug.print($reponse->rowcount());          if ($reponse->rowcount() >0){             debug.print('fetching');             $arr = $reponse->fetchall(pdo::fetch_assoc);                     debug.print($arr);          }      }     catch(exception $e)     {         // en cas d'erreur, on affiche un message et on arrĂȘte tout         $result.=$query . "<br>" . $e->getmessage();         debut.print($result);        }     $bdd=null;  echo $result = json_encode($arr);  ?> 

i think code works expected. think part misleading thinking not $reponse->rowcount().

from php docs,

pdostatement::rowcount() returns number of rows affected last delete, insert, or update statement executed corresponding pdostatement object.

if last sql statement executed associated pdostatement select statement, databases may return number of rows returned statement. however, this behaviour not guaranteed databases , should not relied on portable applications.

so think should switch different row counting method see if changes count. check out these questions

how number of rows grouped column?

row count pdo


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -