public function getTopQuestion($tab = false, $no_answer = false)
    {
        $this->report['value'] = [];
        $this->report['value2'] = [];

        $this->setDateField('log_search.date');
        $sqlBuilder = new module_report_sql($this->app, $this);
        $filter = $sqlBuilder->getFilters()->getReportFilter();
        $params = array_merge([], $filter['params']);

        ($no_answer) ? $this->title = $this->app->trans('report:: questions sans reponses') : $this->title = $this->app->trans('report:: questions les plus posees');

        $sql = "
                SELECT TRIM(log_search.search) AS search, COUNT(log_search.id) AS nb, ROUND(avg(results)) AS nb_rep
                FROM (log_search)
                    INNER JOIN log FORCE INDEX (date_site) ON (log_search.log_id = log.id)
                WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)
                AND log_search.search != 'all' " .
            ($no_answer ? ' AND log_search.results = 0 ' : '') . "

            GROUP BY search
            ORDER BY nb DESC";

// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);

        $sql .= !$no_answer ? ' LIMIT ' . $this->nb_top : '';

        $stmt = $sqlBuilder->getConnBas()->prepare($sql);
        $stmt->execute($params);
        $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
        $stmt->closeCursor();

        $this->setChamp($rs);
        $this->setDisplay($tab);

        $i = 0;
        foreach ($rs as $row) {
            foreach ($this->champ as $value) {
                $this->result[$i][$value] = $row[$value];
            }

            $i++;

            $this->report['legend'][] = $row['search'];
            $this->report['value'][] = $row['nb'];
            $this->report['value2'][] = $row['nb_rep'];
        }

        $this->total = sizeof($this->result);
        //calculate prev and next page
        $this->calculatePages();
        //do we display navigator ?
        $this->setDisplayNav();
        //set report
        $this->setReport();

        return $this->report;
    }
public function getTopQuestion($tab = false, $no_answer = false)
    {
        $this->report['value'] = [];
        $this->report['value2'] = [];

        $this->setDateField('log_search.date');
        $sqlBuilder = new module_report_sql($this->app, $this);
        $filter = $sqlBuilder->getFilters()->getReportFilter();
        $params = array_merge([], $filter['params']);

        ($no_answer) ? $this->title = $this->app->trans('report:: questions sans reponses') : $this->title = $this->app->trans('report:: questions les plus posees');

        $sql = "
                SELECT TRIM(log_search.search) AS search, COUNT(log_search.id) AS nb, ROUND(avg(results)) AS nb_rep
                FROM (log_search)
                    INNER JOIN log FORCE INDEX (date_site) ON (log_search.log_id = log.id)
                WHERE (" . $filter['sql'] . ") AND !ISNULL(usrid)
                AND log_search.search != 'all' " .
            ($no_answer ? ' AND log_search.results = 0 ' : '') . "

            GROUP BY search
            ORDER BY nb DESC";

// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);

        $sql .= !$no_answer ? ' LIMIT ' . $this->nb_top : '';

        $stmt = $sqlBuilder->getConnBas()->prepare($sql);
        $stmt->execute($params);
        $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
        $stmt->closeCursor();

        $this->setChamp($rs);
        $this->setDisplay($tab);

        $i = 0;
        foreach ($rs as $row) {
            foreach ($this->champ as $value) {
                $this->result[$i][$value] = $row[$value];
            }

            $i++;

            $this->report['legend'][] = $row['search'];
            $this->report['value'][] = $row['nb'];
            $this->report['value2'][] = $row['nb_rep'];
        }

        $this->total = sizeof($this->result);
        //calculate prev and next page
        $this->calculatePages();
        //do we display navigator ?
        $this->setDisplayNav();
        //set report
        $this->setReport();

        return $this->report;
    }
public function getTopQuestion ( $ tab = false , $ no_answer = false ) { $ this -> report [ 'value' ] = [ ] ; $ this -> report [ 'value2' ] = [ ] ; $ this -> setDateField ( 'log_search.date' ) ; $ sqlBuilder = new module_report_sql ( $ this -> app , $ this ) ; $ filter = $ sqlBuilder -> getFilters ( ) -> getReportFilter ( ) ; $ params = array_merge ( [ ] , $ filter [ 'params' ] ) ; ( $ no_answer ) ? $ this -> title = $ this -> app -> trans ( 'report:: questions sans reponses' ) : $ this -> title = $ this -> app -> trans ( 'report:: questions les plus posees' ) ; $ sql = "
                SELECT TRIM(log_search.search) AS search, COUNT(log_search.id) AS nb, ROUND(avg(results)) AS nb_rep
                FROM (log_search)
                    INNER JOIN log FORCE INDEX (date_site) ON (log_search.log_id = log.id)
                WHERE (" . $ filter [ 'sql' ] . ") AND !ISNULL(usrid)
                AND log_search.search != 'all' " . ( $ no_answer ? ' AND log_search.results = 0 ' : '' ) . "

            GROUP BY search
            ORDER BY nb DESC" ; // no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND); $ sql .= ! $ no_answer ? ' LIMIT ' . $ this -> nb_top : '' ; $ stmt = $ sqlBuilder -> getConnBas ( ) -> prepare ( $ sql ) ; $ stmt -> execute ( $ params ) ; $ rs = $ stmt -> fetchAll ( PDO :: FETCH_ASSOC ) ; $ stmt -> closeCursor ( ) ; $ this -> setChamp ( $ rs ) ; $ this -> setDisplay ( $ tab ) ; $ i = 0 ; foreach ( $ rs as $ row ) { foreach ( $ this -> champ as $ value ) { $ this -> result [ $ i ] [ $ value ] = $ row [ $ value ] ; } $ i ++ ; $ this -> report [ 'legend' ] [ ] = $ row [ 'search' ] ; $ this -> report [ 'value' ] [ ] = $ row [ 'nb' ] ; $ this -> report [ 'value2' ] [ ] = $ row [ 'nb_rep' ] ; } $ this -> total = sizeof ( $ this -> result ) ; //calculate prev and next page $ this -> calculatePages ( ) ; //do we display navigator ? $ this -> setDisplayNav ( ) ; //set report $ this -> setReport ( ) ; return $ this -> report ; }
get the most asked question
@param array $tab       config for html table
@param bool  $no_answer true for question with no answer
get the most asked question