Welcome Guest, Not a member yet? Register   Sign In
DataMapper - Counting related items
#7

[eluser]WanWizard[/eluser]
That is odd.

Are you sure your models and relations are defined properly? If a person has only one country, there should be a country_id in the persons table and countries.person_id does not exist.
And the count query should be generated on the junction table.

This
Code:
$continent = new Continent(1);
$count = $continent->county->count();

should generate
Code:
SELECT COUNT (`continents_countries`.`country_id`) AS `num_rows' FROM (`continents_countries`) WHERE `continent_id` = 1;

When multiple relations are chained, I expect to see JOIN's in this query.


Messages In This Thread
DataMapper - Counting related items - by El Forum - 03-21-2011, 11:58 AM
DataMapper - Counting related items - by El Forum - 03-21-2011, 05:03 PM
DataMapper - Counting related items - by El Forum - 03-21-2011, 06:06 PM
DataMapper - Counting related items - by El Forum - 03-21-2011, 06:18 PM
DataMapper - Counting related items - by El Forum - 03-22-2011, 01:37 AM
DataMapper - Counting related items - by El Forum - 03-22-2011, 03:53 AM
DataMapper - Counting related items - by El Forum - 03-22-2011, 05:45 AM
DataMapper - Counting related items - by El Forum - 03-24-2011, 07:50 AM
DataMapper - Counting related items - by El Forum - 11-22-2012, 12:22 PM
DataMapper - Counting related items - by El Forum - 11-22-2012, 02:03 PM
DataMapper - Counting related items - by El Forum - 11-23-2012, 01:27 AM
DataMapper - Counting related items - by El Forum - 11-23-2012, 03:39 AM
DataMapper - Counting related items - by El Forum - 11-23-2012, 07:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB