public static function count_templates($competencyid, $onlyvisible) {
        global $DB;

        $sql = 'SELECT COUNT(tpl.id)
                  FROM {' . self::TABLE . '} tplcomp
                  JOIN {' . template::TABLE . '} tpl
                    ON tplcomp.templateid = tpl.id
                 WHERE tplcomp.competencyid = ? ';
        $params = array($competencyid);

        if ($onlyvisible) {
            $sql .= ' AND tpl.visible = ?';
            $params[] = 1;
        }

        $results = $DB->count_records_sql($sql, $params);

        return $results;
    }
public static function count_templates($competencyid, $onlyvisible) {
        global $DB;

        $sql = 'SELECT COUNT(tpl.id)
                  FROM {' . self::TABLE . '} tplcomp
                  JOIN {' . template::TABLE . '} tpl
                    ON tplcomp.templateid = tpl.id
                 WHERE tplcomp.competencyid = ? ';
        $params = array($competencyid);

        if ($onlyvisible) {
            $sql .= ' AND tpl.visible = ?';
            $params[] = 1;
        }

        $results = $DB->count_records_sql($sql, $params);

        return $results;
    }
public static function count_templates ( $ competencyid , $ onlyvisible ) { global $ DB ; $ sql = 'SELECT COUNT(tpl.id)
                  FROM {' . self :: TABLE . '} tplcomp
                  JOIN {' . template :: TABLE . '} tpl
                    ON tplcomp.templateid = tpl.id
                 WHERE tplcomp.competencyid = ? ' ; $ params = array ( $ competencyid ) ; if ( $ onlyvisible ) { $ sql .= ' AND tpl.visible = ?' ; $ params [ ] = 1 ; } $ results = $ DB -> count_records_sql ( $ sql , $ params ) ; return $ results ; }
Count the templates using a competency.

@param int $competencyid The competency id
@param bool $onlyvisible If true, only count visible templates using this competency.
@return int
Count the templates using a competency .