Show
Ignore:
Timestamp:
06/21/09 21:12:22 (1 year ago)
Author:
bermi
Message:

Has many counter SQL now works when calling it without requiring a previous owner inclussion.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/AkActiveRecord/AkAssociations/AkHasMany.php

    r1311 r1324  
    499499 
    500500        if(!empty($options['counter_sql']) && strtoupper(substr($options['counter_sql'],0,6)) != 'SELECT'){ 
    501             $options['counter_sql'] = 'SELECT COUNT(*) FROM '.$table_name.' WHERE '.$options['counter_sql']; 
     501            $count_table_name = $table_name == '__owner' ?  $Associated->getTableName().' as __owner' : $table_name; 
     502            $options['counter_sql'] = 'SELECT COUNT(*) FROM '.$count_table_name.' WHERE '.$options['counter_sql']; 
    502503        } 
    503504