- // Now update the tc_district table appropriately
-
- // Delete all the previous district entries from the table
- $this->db->query("DELETE from tc_district where valid=1",__LINE__,__FILE__);
- $this->db->query("DELETE from tc_district where valid=0",__LINE__,__FILE__);
-
- // Always add a "District 0" assigned to the High Priests Group
- $district = 0;
- $name = "High Priests";
- $indiv = 0;
- $valid = 0;
- $this->db2->query("INSERT INTO tc_district (district,leader,valid) " .
- "VALUES ('" . $district . "','" .
- $indiv . "','" . $valid . "'" .
- ")",__LINE__,__FILE__);
-
- // Requery the tc_leader table
- $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.valid=1";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record()) {
- // Extract the data for each leader record
- $id = $this->db->f('leader');
- $indiv = $this->db->f('individual');
- $name = $this->db->f('name');
- $district = $this->db->f('district');
- $valid = 1;
-
- // If we have a valid district, add it to the district table
- if($district > 0) {
- $this->db2->query("INSERT INTO tc_district (district,leader,valid) " .
- "VALUES ('" . $district . "','" .
- $indiv . "','" . $valid . "'" .
- ")",__LINE__,__FILE__);
- }
- }
-