add optional parameters to getDocumentsByCategory, new method countDocumentsByCategory

This commit is contained in:
Uwe Steinmann 2017-12-04 15:22:48 +01:00
parent c21388fd72
commit 822e6c13f2

View File

@ -98,10 +98,14 @@ class SeedDMS_Core_DocumentCategory {
return true;
} /* }}} */
function getDocumentsByCategory() { /* {{{ */
function getDocumentsByCategory($limit=0, $offset=0) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblDocumentCategory` where `categoryID`=".$this->_id;
if($limit && is_numeric($limit))
$queryStr .= " LIMIT ".(int) $limit;
if($offset && is_numeric($offset))
$queryStr .= " OFFSET ".(int) $offset;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
@ -113,6 +117,17 @@ class SeedDMS_Core_DocumentCategory {
return $documents;
} /* }}} */
function countDocumentsByCategory() { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT COUNT(*) as `c` FROM `tblDocumentCategory` where `categoryID`=".$this->_id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
return $resArr[0]['c'];
} /* }}} */
}
?>