コード例 #1
0
ファイル: FunctionsImport.php プロジェクト: tronsmit/webtrees
 /**
  * Extract all the names from the given record and insert them into the database.
  *
  * @param string       $xref
  * @param int          $ged_id
  * @param GedcomRecord $record
  */
 public static function updateNames($xref, $ged_id, GedcomRecord $record)
 {
     foreach ($record->getAllNames() as $n => $name) {
         if ($record instanceof Individual) {
             if ($name['givn'] === '@P.N.') {
                 $soundex_givn_std = null;
                 $soundex_givn_dm = null;
             } else {
                 $soundex_givn_std = Soundex::russell($name['givn']);
                 $soundex_givn_dm = Soundex::daitchMokotoff($name['givn']);
             }
             if ($name['surn'] === '@N.N.') {
                 $soundex_surn_std = null;
                 $soundex_surn_dm = null;
             } else {
                 $soundex_surn_std = Soundex::russell($name['surname']);
                 $soundex_surn_dm = Soundex::daitchMokotoff($name['surname']);
             }
             Database::prepare("INSERT INTO `##name` (n_file,n_id,n_num,n_type,n_sort,n_full,n_surname,n_surn,n_givn,n_soundex_givn_std,n_soundex_surn_std,n_soundex_givn_dm,n_soundex_surn_dm) VALUES (?, ?, ?, ?, LEFT(?, 255), LEFT(?, 255), LEFT(?, 255), LEFT(?, 255), ?, ?, ?, ?, ?)")->execute(array($ged_id, $xref, $n, $name['type'], $name['sort'], $name['fullNN'], $name['surname'], $name['surn'], $name['givn'], $soundex_givn_std, $soundex_surn_std, $soundex_givn_dm, $soundex_surn_dm));
         } else {
             Database::prepare("INSERT INTO `##name` (n_file,n_id,n_num,n_type,n_sort,n_full) VALUES (?, ?, ?, ?, LEFT(?, 255), LEFT(?, 255))")->execute(array($ged_id, $xref, $n, $name['type'], $name['sort'], $name['fullNN']));
         }
     }
 }