Пример #1
0
 /**
  *
  * @param ResultWrapper $results Results from SQL select
  * @param DatabaseBase $databaseBase Optoional, default = wfGetDB(DB_SLAVE)
  * @return array Array of WpInvitationCategory (indexes are categories identifiers)
  */
 private static function factoryFromResults($results)
 {
     if (!$results instanceof ResultWrapper) {
         return array();
     }
     $categories = array();
     $category = null;
     foreach ($results as $row) {
         if ($category == null) {
             $category = self::constructFromDatabaseRow($row);
             $category->plans = array();
         } elseif ($category->getId() != $row->wpic_id) {
             $categories[$category->getId()] = $category;
             $category = self::constructFromDatabaseRow($row);
             $category->plans = array();
         }
         if ($row->wpp_id != null) {
             $plan = WpPlan::constructFromDatabaseRow($row);
             if ($plan != null) {
                 $category->plans[] = $plan;
             }
         }
     }
     if ($category != null) {
         $categories[$category->getId()] = $category;
     }
     return $categories;
 }