Ticket #19 (closed enhancement: fixed)
getCount() - a single method for counting records
| Reported by: | dartar | Owned by: | DotMG |
|---|---|---|---|
| Priority: | high | Milestone: | 1.3.1 |
| Component: | core | Version: | 1.1.6.0 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
There are numerous places in Wikka where we need to know "how many" of a certain thing there are in the database: how many pages, how many comments, how many pages owned by the logged-in user, ... etc. And there will be more.
Currently all these counts are retrieved via different methods: sometimes building a query and getting the count directly (the most efficient way); sometimes by using the LoadSingle() method after building a query, which is highly inefficient, as it effectively first asks MySQL to assign a name to the count and return records in an associative array, then retrieves the first (only!) item from the array of records, and finally retrieves the number from the associative array by name.
A single method
To avoid all this inconsistency and inefficiency, here is a simple method that does nothing but retrieve a count and return it as an integer.
Status
tested
To do
All actions, handlers and core methods that used different kinds of query to count records should be modified to use this new method. Instructions are given on the source page.