function critere_compteur($idb, &$boucles, $crit){ $boucle = &$boucles[$idb]; $params = $crit->param; $table = array_shift($params); $table = $table[0]->texte; if(preg_match(',^(\w+)([<>=])([0-9]+)$,',$table,$r)){ $table=$r[1]; $op=$r[2]; $op_val=$r[3]; } $type = objet_type($table); $type_id = id_table_objet($type); $table_sql = table_objet_sql($type); $trouver_table = charger_fonction('trouver_table','base'); $arrivee = array($table, $trouver_table($table, $boucle->sql_serveur)); $depart = array($boucle->id_table,$trouver_table($boucle->id_table, $boucle->sql_serveur)); if ($compt = calculer_jointure($boucle,$depart,$arrivee)){ $boucle->select[]= "COUNT($compt.$type_id) AS compteur_$table"; if ($op) $boucle->having[]= array("'".$op."'", "'compteur_".$table."'",$op_val); } } function balise_COMPTEUR_dist($p) { $p->code = ''; if (isset($p->param[0][1][0]) AND $champ = ($p->param[0][1][0]->texte)) return rindex_pile($p, "compteur_$champ", 'compteur'); return $p; }