public function count() {
        global $DB;
        if ($this->totalcommentcount === null) {
            list($where, $component) = $this->get_component_select_sql();
            $where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid';
            $params = array(
                'itemid' => $this->itemid,
                'commentarea' => $this->commentarea,
                'contextid' => $this->context->id,
            );
            if ($component) {
                $params['component'] = $component;
            }

            $this->totalcommentcount = $DB->count_records_select('comments', $where, $params);
        }
        return $this->totalcommentcount;
    }
public function count() {
        global $DB;
        if ($this->totalcommentcount === null) {
            list($where, $component) = $this->get_component_select_sql();
            $where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid';
            $params = array(
                'itemid' => $this->itemid,
                'commentarea' => $this->commentarea,
                'contextid' => $this->context->id,
            );
            if ($component) {
                $params['component'] = $component;
            }

            $this->totalcommentcount = $DB->count_records_select('comments', $where, $params);
        }
        return $this->totalcommentcount;
    }
public function count ( ) { global $ DB ; if ( $ this -> totalcommentcount === null ) { list ( $ where , $ component ) = $ this -> get_component_select_sql ( ) ; $ where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid' ; $ params = array ( 'itemid' => $ this -> itemid , 'commentarea' => $ this -> commentarea , 'contextid' => $ this -> context -> id , ) ; if ( $ component ) { $ params [ 'component' ] = $ component ; } $ this -> totalcommentcount = $ DB -> count_records_select ( 'comments' , $ where , $ params ) ; } return $ this -> totalcommentcount ; }
Returns the number of comments associated with the details of this object

@global moodle_database $DB
@return int
Returns the number of comments associated with the details of this object