/**
  * Recover all the rector from one church
  *
  * @author Jonathan Sandoval <*****@*****.**>
  * @param  string          $idChurch   Id of one church
  * @return Array[Church]               Rector that worked in the church
  */
 static function getAllFormerChurchs($idRector = '', $order = 'id', $begin = -1)
 {
     if ($idRector == '') {
         return null;
     } else {
         $tableRector = DatabaseManager::getNameTable('TABLE_RECTOR');
         $tableChurch = DatabaseManager::getNameTable('TABLE_CHURCH');
         $tablePerson = DatabaseManager::getNameTable('TABLE_PERSON');
         $tableUnion = DatabaseManager::getNameTable('TABLE_FORMER_RECTOR_CHURCH');
         $query = "SELECT {$tableChurch}.*\r\n                              FROM {$tableChurch}\r\n                              LEFT JOIN {$tableUnion}\r\n                              ON {$tableUnion}.idChurch = {$tableChurch}.id\r\n                              WHERE {$tableUnion}.idRector = {$idRector}\r\n                              ORDER BY {$order}";
         if ($begin !== -1) {
             $query = $query . " LIMIT " . strval($begin * 10) . ", 11 ";
         }
         $arrayChurchs = DatabaseManager::multiFetchAssoc($query);
         $churchs = array();
         if ($arrayChurchs === null) {
             return null;
         } else {
             if ($begin !== -1) {
                 $i = 0;
                 foreach ($arrayChurchs as $church) {
                     if ($i == 10) {
                         continue;
                     }
                     $churchs[] = ChurchManager::ArrayToChurch($church);
                     $i++;
                 }
             } else {
                 foreach ($arrayChurchs as $church) {
                     $churchs[] = ChurchManager::ArrayToChurch($church);
                 }
             }
             return $churchs;
         }
     }
 }