compter les articles d'une table

loul1933 07 Jan, 2013
Bonjour,
Je suis en jommla 2.5
Je cherche un bout de script dans chronoconnectivity pour compter les articles d'une table mysql
Le code de Bob de l'ancienne version:
<?php
// get the number of records returned
$db =& JFactory::getDBO();
global $count;
$count =$db->loadResult();
echo $count;
?>

ne renvoie pas le nombre d'articles trouvé dans la table, mais la valeur de la première colonne du premier article!!!

Je voudrais juste afficher le nombre d'article trouvé par la requete "Where"

Excusez moi d'avance pour le français

Cordialement
Jean Louis

NB la nouvelle presentation de chronoconnectivity est certe plus riche, mais "perturbante"
GreyHead 07 Jan, 2013
Bonjour Jean Louis,

As far as I can see the current version of ChronoConnectivity doesn't make the total count available :-( It would be possible to hack the code to do so as the query is run to set the pagination parameters. Otherwise I the only answer I can think of is to use the Custom Settings and to repeat the query in the Header box.

Bob

NB la nouvelle presentation de chronoconnectivity est certe plus riche, mais "perturbante"

Je suis d'accord !
loul1933 07 Jan, 2013
Thank's Bob,
je ne comprenais pas et votre réponse me rassure!

I try to put the query in the header box, but in this case, i clear the where sql box ??
and the request is an sql request "normale"?

Cordialement
Jean louis
GreyHead 08 Jan, 2013
Hi Jean louis,

I think you'd need to leave the WHERE box unchanged but repeat the whole query in the Header box to get the count.
<?php
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__some_table`
        WHERE `xxx` = 'yyy' ;
";
$db->setQuery($query);
$count = $db->loadResult();
?>

Bob
This topic is locked and no more replies can be posted.