sort() публичный Метод

public sort ( $cmpFunction )
Пример #1
0
 /**
  * Generate the join sql based on the needed tables
  * @throws Exception if tables can't be joined
  * @return array
  */
 public function generate()
 {
     /** @var LogTable[] $availableLogTables */
     $availableLogTables = array();
     $this->tables->sort(array($this, 'sortTablesForJoin'));
     foreach ($this->tables as $i => $table) {
         if (is_array($table)) {
             // join condition provided
             $alias = isset($table['tableAlias']) ? $table['tableAlias'] : $table['table'];
             $this->joinString .= " LEFT JOIN " . Common::prefixTable($table['table']) . " AS " . $alias . " ON " . $table['joinOn'];
             continue;
         }
         $tableSql = Common::prefixTable($table) . " AS {$table}";
         $logTable = $this->tables->getLogTable($table);
         if ($i == 0) {
             // first table
             $this->joinString .= $tableSql;
         } else {
             $join = $this->findJoinCriteriasForTables($logTable, $availableLogTables);
             if ($join === null) {
                 $availableLogTables[$table] = $logTable;
                 continue;
             }
             // the join sql the default way
             $this->joinString .= " LEFT JOIN {$tableSql} ON " . $join;
         }
         $availableLogTables[$table] = $logTable;
     }
 }