[eluser]Nicolas Connault[/eluser]
Hi everyone! I've been coding with CI for a number of months now, and so far I've always found the help I needed from the User Guide and the existing posts on the forums.
Now I'm stumped. I have a situation in which a data table is made up of a variety of fields from joined tables, including a custom field made up of a concatenation of fields from two different tables.
I want to be able to filter the table by the custom field (let's called it "custom_field").
However, because of pagination requirements, I must first obtain a total number of records returned by that query. Because of the level of abstraction in which I'm working (this is all setup in MY_Controller and used by a dozen controllers with different models and DB schemas), I have to use activerecord's count_all_results() to get that number.
Unfortunately, doing a count that way wipes out my custom field, since only COUNT(*) is selected. The other way to count would be to use $query->num_rows after running the full query, but doing this would be computationally expensive, and I only ever want to fetch 20 records at a time.
Has anyone come across that situation before? Any ideas?