- getDocumentCategoryByName() returns just one category

This commit is contained in:
steinm 2011-07-20 16:47:09 +00:00
parent afb4774ada
commit 63bf8505a8

View File

@ -923,6 +923,14 @@ class LetoDMS_Core_DMS {
return $categories;
} /* }}} */
/**
* Get a category by its name
*
* The name of a category is by default unique.
*
* @param string $name human readable name of category
* @return object instance of LetoDMS_Core_DocumentCategory
*/
function getDocumentCategoryByName($name) { /* {{{ */
$queryStr = "SELECT * FROM tblCategory where name='".$name."'";
@ -930,14 +938,11 @@ class LetoDMS_Core_DMS {
if (is_bool($resArr) && !$resArr)
return false;
$categories = array();
foreach ($resArr as $row) {
$cat = new LetoDMS_Core_DocumentCategory($row["id"], $row["name"]);
$cat->setDMS($this);
array_push($categories, $cat);
}
$row = $resArr[0];
$cat = new LetoDMS_Core_DocumentCategory($row["id"], $row["name"]);
$cat->setDMS($this);
return $categories;
return $cat;
} /* }}} */
function addDocumentCategory($name) { /* {{{ */