• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space

Number of images in each category ?

SQL:
SELECT i.image_category_id id, c.category_name name, COUNT(1) count
FROM chv_images i
LEFT JOIN chv_categories c ON c.category_id = i.image_category_id
WHERE i.image_category_id IS NOT NULL
GROUP BY i.image_category_id;

1530721329730.png

Do please note that this is an expensive query. Don't call it on every request.
 
You must execute that query using CHV\DB. I must insist, DO NOT call that query on every request. It will eat like 2 seconds of request time and it could compromise your server (ddos).

PHP:
$fetch = CHV\DB::queryFetchAll('
SELECT i.image_category_id id, c.category_name name, COUNT(1) count
FROM chv_images i
LEFT JOIN chv_categories c ON c.category_id = i.image_category_id
WHERE i.image_category_id IS NOT NULL
GROUP BY i.image_category_id;');

$fetch will contain the resultset array.
 
Back
Top