Welcome Guest, Not a member yet? Register   Sign In
Pagination with sorting
#9

[eluser]dmorin[/eluser]
It sounds like CI might be escaping the whole count block of text causing mysql to look for it as a column. The problem isn't that it's trying to count from account, it's that it's looking for a column named "count(mrc...)" What version of CI are you using? If 1.7.0 I would recommend upgrading to 1.7.1 as it deals with db escaping much better.

A way to test this is the set the second parameter of the SELECT method to FALSE. So:

Code:
$this->db->select('a.id, a.name, a.billing_address_street,
        a.billing_address_city, a.billing_address_state, a.billing_address_postalcode,
        a.billing_address_country, a.website, a.description, a.eighthundrednumber_c,
        a.mechanixlooprating_c, a.extension_c, a.petfriendly_c, a.womenowned_c, a.providearide_c,
        count(mrc.id) as num_reviews', FALSE);

let me know if that changes anything.

EDIT:
I also just looked more closely at what you tried and it looks like you're trying to include where-like strings in your select which is bad. Things like "mrc.userid_c = a.id" are done in the JOIN criteria or the Where portion, NOT in the select. The exception is when you're doing an entire subquery, but those are usually really bad/inefficient.

EDIT2:
I just noticed you posted the resulting SQL and I was right that CI is adding ticks around the whole count item. Try setting the second param to FALSE as I mentioned above and see what that does.


Messages In This Thread
Pagination with sorting - by El Forum - 02-27-2009, 11:21 AM
Pagination with sorting - by El Forum - 02-27-2009, 11:39 AM
Pagination with sorting - by El Forum - 02-27-2009, 12:26 PM
Pagination with sorting - by El Forum - 02-27-2009, 12:48 PM
Pagination with sorting - by El Forum - 02-27-2009, 01:39 PM
Pagination with sorting - by El Forum - 02-27-2009, 01:54 PM
Pagination with sorting - by El Forum - 02-27-2009, 02:10 PM
Pagination with sorting - by El Forum - 02-27-2009, 02:19 PM
Pagination with sorting - by El Forum - 02-27-2009, 02:36 PM
Pagination with sorting - by El Forum - 02-27-2009, 02:47 PM
Pagination with sorting - by El Forum - 02-27-2009, 02:52 PM
Pagination with sorting - by El Forum - 02-27-2009, 02:58 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:08 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:16 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:27 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:28 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:34 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:40 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:42 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:52 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:56 PM
Pagination with sorting - by El Forum - 02-27-2009, 03:58 PM
Pagination with sorting - by El Forum - 02-27-2009, 04:09 PM
Pagination with sorting - by El Forum - 02-27-2009, 04:43 PM
Pagination with sorting - by El Forum - 02-27-2009, 07:10 PM
Pagination with sorting - by El Forum - 02-27-2009, 07:29 PM
Pagination with sorting - by El Forum - 02-27-2009, 07:52 PM
Pagination with sorting - by El Forum - 02-27-2009, 08:00 PM
Pagination with sorting - by El Forum - 02-27-2009, 10:20 PM
Pagination with sorting - by El Forum - 02-28-2009, 09:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB