I would like to count the number of nums in a table from the associated idnr. However, I get the following error message: Fatal error: Uncaught MeekroDBException: If you use named args, you must pass an assoc array of args!
The table looks like this:
+---------+---------+-----------------------+
| idnr | nums | timestamp |
+---------+---------+-----------------------+
| 1234 | 75 | 2021-10-19 11:59:22 |
| 1234 | 73 | 2021-11-09 11:59:22 |
| 1234 | 43 | 2020-07-19 12:59:22 |
| 4565 | 31 | 2021-11-19 13:59:22 |
+---------+---------+-----------------------+
The SQL string:
$results = DB::query("SELECT COUNT(nums) FROM tablename WHERE idnr = %i_idnr", '1234');
And I want to show it like:
echo $results['nums']; // the result should be 148
Thanks a lot ;)
Well, your error describes itself.
From the MeekroDB docs:
Example code:
So in your case it would be:
A few more notes: