I am trying to get results from my database with details covering the tables "places", "category" and "reviews", and then sort by the number of reviews. When I add the second connection, only one row is retrieved.
$this->db->select('places.*, category.*')
->from('places')
->join('category', 'places.category_id = category.category_id')
->join('places_reviews', 'places_reviews.place_id = places.id')
->where('places.category_id', $category_id)
->limit($limit, $offset)
->order_by($sort_by, $sort_order);
I did not add IFNULL(COUNT(places_reviews('review_id')) AS 'num_reviews', 0)select () to the code to clear the code.
Any ideas?
source
share