I am querying a database with $votes = Db::select($table, ['votes']);
. The ‘votes’ column is of the JSON type. This gives me a Kirby collection. When getting the values of this collection, I receive this array:
Array
(
[0] => Kirby\Toolkit\Obj Object
(
[votes] => [{"rate": "4", "video": "2"}, {"rate": "2", "video": "6"}, {"rate": "4", "video": "8"}, {"rate": "4", "video": "9"}]
)
[1] => Kirby\Toolkit\Obj Object
(
[votes] => [{"rate": "4", "video": "8"}]
)
[2] => Kirby\Toolkit\Obj Object
(
[votes] => [{"rate": "4", "video": "7"}, {"rate": "3", "video": "8"}, {"rate": "3", "video": "9"}]
)
// ect
)
Now, I want to collect every vote object {"rate": x, "video": n}
in a new array, in order to perform some operations on the whole data set. If it helps, I want to count all votes, find the average rating for each video and more. This whole procedure should probably be done in SQL, but I don’t know the language.