$allCategories = $this->task->categoryModel->getAll();
Can anybody help me fix this? I am trying to call a count of total categories in a plugin from the category table,
regardless of project.
I’m calling like this:
<?= count($allCategories) ?>
The problem is, I don’t know how to call it without a
I found a solution in a different kind of way.
Would you mind telling?
All categories are in stores in the table
project_has_categories. I’d write a function to get that content directly.
SELECT COUNT (*) FROM project_has_categories;
Or you iterate through the projects and then through its categories.
hello, I did this:
$allCategories = $this->task->db->table('project_has_categories')->count();
<?= $allCategories ?>
to show as:
But, if you go via tasks, you’ll omit the global categories, not assigned to a task. Don’t you?
no,… you have to use
task if using through a plugin, without it, the entry doesnt work. Also, the data is correct as I am crosschecking it with my working database. All them total are global numbers, per kanboard installation which is the intention.
OK, this might work, but IMHO the clean way would be extending the CategoryModel class, adding the missing functions, like e.g. getCategoryCount(). But maybe I miss something.
I followed this, which made access to the database a lot easier once I figured out how to convert the statement
This file has been truncated.
PicoDb is a minimalist database query builder for PHP.
- Easy to use, easy to hack, fast and very lightweight
- Supported drivers: Sqlite, Mssql, Mysql, Postgresql
- Requires only PDO
- Use prepared statements
- Handle schema migrations
- Fully unit tested on PHP 5.3, 5.4, 5.5, 5.6 and 7.0
- License: MIT
- PHP >= 5.3
January 28, 2023, 10:06am
Yes, of course you should always use the query builder. But this was not the point. I just dislike going via a task, where this is not required. But it’s your decision at the end.
oh I think I have not explained it properly… I am not going via a task… but in to make the variable work via a plugin, you must use via task… although it is not actually going through a task. If you try the code without via task, you will get undefined variable.
I read it in the docs and then @creecros confirmed the same.