Merge pull request #14420 from egils-consulting/patch-5
New function count_all_categories
This commit is contained in:
commit
a32587d993
@ -2010,4 +2010,25 @@ class Categorie extends CommonObject
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count all categories
|
||||||
|
*
|
||||||
|
* @return int Number of categories, -1 on error
|
||||||
|
*/
|
||||||
|
public function countNbOfCategories()
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::count_all_categories", LOG_DEBUG);
|
||||||
|
$sql = "SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."categorie";
|
||||||
|
$sql .= " WHERE entity IN (".getEntity('category').")";
|
||||||
|
|
||||||
|
$res = $this->db->query($sql);
|
||||||
|
if ($res) {
|
||||||
|
$obj = $this->db->fetch_object($res);
|
||||||
|
return $obj->count;
|
||||||
|
} else {
|
||||||
|
dol_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user