applications/dashboard/models/class.importmodel.php
public function GetCountSQL(
      $Aggregate, // count, max, min, etc.
      $ParentTable, $ChildTable, 
      $ParentColumnName = '', $ChildColumnName = '',
      $ParentJoinColumn = '', $ChildJoinColumn = '') {

      if(!$ParentColumnName) {
         switch(strtolower($Aggregate)) {
            case 'count': $ParentColumnName = "Count{$ChildTable}s"; break;
            case 'max': $ParentColumnName = "Last{$ChildTable}ID"; break;
            case 'min': $ParentColumnName = "First{$ChildTable}ID"; break;
            case 'sum': $ParentColumnName = "Sum{$ChildTable}s"; break;
         }
      }

      if(!$ChildColumnName)
         $ChildColumnName = $ChildTable.'ID';

      if(!$ParentJoinColumn)
         $ParentJoinColumn = $ParentTable.'ID';
      if(!$ChildJoinColumn)
         $ChildJoinColumn = $ParentJoinColumn;

      $Result = "update :_$ParentTable p
                  set p.$ParentColumnName = (
                     select $Aggregate(c.$ChildColumnName)
                     from :_$ChildTable c
                     where p.$ParentJoinColumn = c.$ChildJoinColumn)";
      return $Result;
   }
public function GetCountSQL(
      $Aggregate, // count, max, min, etc.
      $ParentTable, $ChildTable, 
      $ParentColumnName = '', $ChildColumnName = '',
      $ParentJoinColumn = '', $ChildJoinColumn = '') {

      if(!$ParentColumnName) {
         switch(strtolower($Aggregate)) {
            case 'count': $ParentColumnName = "Count{$ChildTable}s"; break;
            case 'max': $ParentColumnName = "Last{$ChildTable}ID"; break;
            case 'min': $ParentColumnName = "First{$ChildTable}ID"; break;
            case 'sum': $ParentColumnName = "Sum{$ChildTable}s"; break;
         }
      }

      if(!$ChildColumnName)
         $ChildColumnName = $ChildTable.'ID';

      if(!$ParentJoinColumn)
         $ParentJoinColumn = $ParentTable.'ID';
      if(!$ChildJoinColumn)
         $ChildJoinColumn = $ParentJoinColumn;

      $Result = "update :_$ParentTable p
                  set p.$ParentColumnName = (
                     select $Aggregate(c.$ChildColumnName)
                     from :_$ChildTable c
                     where p.$ParentJoinColumn = c.$ChildJoinColumn)";
      return $Result;
   }
public function GetCountSQL ( $ Aggregate , // count, max, min, etc.
 $ ParentTable , $ ChildTable , $ ParentColumnName = '' , $ ChildColumnName = '' , $ ParentJoinColumn = '' , $ ChildJoinColumn = '' ) { if ( ! $ ParentColumnName ) { switch ( strtolower ( $ Aggregate ) ) { case 'count' : $ ParentColumnName = "Count{$ChildTable}s" ; break ; case 'max' : $ ParentColumnName = "Last{$ChildTable}ID" ; break ; case 'min' : $ ParentColumnName = "First{$ChildTable}ID" ; break ; case 'sum' : $ ParentColumnName = "Sum{$ChildTable}s" ; break ; } } if ( ! $ ChildColumnName ) $ ChildColumnName = $ ChildTable . 'ID' ; if ( ! $ ParentJoinColumn ) $ ParentJoinColumn = $ ParentTable . 'ID' ; if ( ! $ ChildJoinColumn ) $ ChildJoinColumn = $ ParentJoinColumn ; $ Result = "update :_$ParentTable p
                  set p.$ParentColumnName = (
                     select $Aggregate(c.$ChildColumnName)
                     from :_$ChildTable c
                     where p.$ParentJoinColumn = c.$ChildJoinColumn)" ; return $ Result ; }
Return SQL for updating a count.
@param string $Aggregate count, max, min, etc.
@param string $ParentTable The name of the parent table.
@param string $ChildTable The name of the child table
@param type $ParentColumnName
@param string $ChildColumnName
@param string $ParentJoinColumn
@param string $ChildJoinColumn
@return type
Return SQL for updating a count .