$reviews = DB::select('reviews.*', DB::expr('count(*) as count')) ->from('reviews') ->group_by('thing_id') ->as_object('Model_Review')->execute();Which results in the error:
I want to return all reviews unique to a particular 'thing' but I'd also like to have a count of the number of times that thing has been reviewed. I get an error because count is not in the Review model. One quick hack I did to stop the error was just to add count to the model - obviously this is not right and now I'm paying the price for it. I'm thinking maybe I could create an extra model that contained just count and review_id and then lazy loading the actual review in from the ORM - this doesn't seem right either. Is this something anyone's come across? Thanks MikePDOException [ HY000 ]: SQLSTATE[HY000]: General error: could not call class constructor
It looks like you're new here. If you want to get involved, click one of these buttons!