public function getOffset($Comment)
{
$this->fireEvent('BeforeGetOffset');
if (is_numeric($Comment)) {
$Comment = $this->getID($Comment);
}
$this->SQL->select('c.CommentID', 'count', 'CountComments')->from('Comment c')->where('c.DiscussionID', val('DiscussionID', $Comment));
$this->SQL->beginWhereGroup();
// Figure out the where clause based on the sort.
foreach ($this->_OrderBy as $Part) {
//$Op = count($this->_OrderBy) == 1 || isset($PrevWhere) ? '=' : '';
list($Expr, $Value) = $this->_WhereFromOrderBy($Part, $Comment, '');
if (!isset($PrevWhere)) {
$this->SQL->where($Expr, $Value);
} else {
$this->SQL->orOp();
$this->SQL->beginWhereGroup();
$this->SQL->orWhere($PrevWhere[0], $PrevWhere[1]);
$this->SQL->where($Expr, $Value);
$this->SQL->endWhereGroup();
}
$PrevWhere = $this->_WhereFromOrderBy($Part, $Comment, '==');
}
$this->SQL->endWhereGroup();
return $this->SQL->get()->firstRow()->CountComments;
}