summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/functions/functions_db.php101
1 files changed, 44 insertions, 57 deletions
diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php
index d5fb25e491..4e3cf6a5f5 100644
--- a/includes/functions/functions_db.php
+++ b/includes/functions/functions_db.php
@@ -111,58 +111,55 @@ function get_note_list($ged_id) {
return $list;
}
-
-// Search for INDIs using custom SQL generated by the report engine
+/**
+ * Search for INDIs using custom SQL generated by the report engine
+ *
+ * @todo This function is only used by the report engine. Move the code there.
+ *
+ * @param string $join
+ * @param string[] $where
+ * @param string[] $order
+ *
+ * @return WT_Individual[]
+ */
function search_indis_custom($join, $where, $order) {
- $sql="SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom FROM `##individuals` ".implode(' ', $join).' WHERE '.implode(' AND ', $where);
+ $sql = "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom FROM `##individuals` ".implode(' ', $join).' WHERE '.implode(' AND ', $where);
if ($order) {
- $sql.=' ORDER BY '.implode(' ', $order);
+ $sql .= ' ORDER BY '.implode(' ', $order);
}
- $list=array();
- $rows=WT_DB::prepare($sql)->fetchAll();
- $GED_ID=WT_GED_ID;
+ $list = array();
+ $rows = WT_DB::prepare($sql)->fetchAll();
foreach ($rows as $row) {
- // Switch privacy file if necessary
- if ($row->gedcom_id!=$GED_ID) {
- $GEDCOM=get_gedcom_from_id($row->gedcom_id);
- load_gedcom_settings($row->gedcom_id);
- $GED_ID=$row->gedcom_id;
- }
- $list[]=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
- }
- // Switch privacy file if necessary
- if ($GED_ID!=WT_GED_ID) {
- $GEDCOM=WT_GEDCOM;
- load_gedcom_settings(WT_GED_ID);
+ $list[] = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
}
+
return $list;
}
-// Search for FAMs using custom SQL generated by the report engine
+/**
+ * Search for FAMs using custom SQL generated by the report engine
+ *
+ * @todo This function is only used by the report engine. Move the code there.
+ *
+ * @param string $join
+ * @param string[] $where
+ * @param string[] $order
+ *
+ * @return WT_Family[]
+ */
function search_fams_custom($join, $where, $order) {
- $sql="SELECT DISTINCT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` ".implode(' ', $join).' WHERE '.implode(' AND ', $where);
+ $sql = "SELECT DISTINCT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` ".implode(' ', $join).' WHERE '.implode(' AND ', $where);
if ($order) {
- $sql.=' ORDER BY '.implode(' ', $order);
+ $sql .= ' ORDER BY '.implode(' ', $order);
}
- $list=array();
- $rows=WT_DB::prepare($sql)->fetchAll();
- $GED_ID=WT_GED_ID;
+ $list = array();
+ $rows = WT_DB::prepare($sql)->fetchAll();
foreach ($rows as $row) {
- // Switch privacy file if necessary
- if ($row->gedcom_id!=$GED_ID) {
- $GEDCOM=get_gedcom_from_id($row->gedcom_id);
- load_gedcom_settings($row->gedcom_id);
- $GED_ID=$row->gedcom_id;
- }
- $list[]=WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
- }
- // Switch privacy file if necessary
- if ($GED_ID!=WT_GED_ID) {
- $GEDCOM=WT_GEDCOM;
- load_gedcom_settings(WT_GED_ID);
+ $list[] = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
}
+
return $list;
}
@@ -303,13 +300,14 @@ function search_indis_soundex($soundex, $lastname, $firstname, $place, $geds) {
$plac_sdx = WT_Soundex::soundex_std($place);
$field = 'std';
break;
- default:
case 'DaitchM':
$givn_sdx = WT_Soundex::soundex_dm($firstname);
$surn_sdx = WT_Soundex::soundex_dm($lastname);
$plac_sdx = WT_Soundex::soundex_dm($place);
$field = 'dm';
break;
+ default:
+ throw new InvalidArgumentException('soundex: ' . $soundex);
}
// Nothing to search for? Return nothing.
@@ -346,36 +344,25 @@ function search_indis_soundex($soundex, $lastname, $firstname, $place, $geds) {
// Group results by gedcom, to minimise switching between privacy files
$sql .= ' ORDER BY gedcom_id';
- $list=array();
- $rows=WT_DB::prepare($sql)->execute($sql_args)->fetchAll();
- $GED_ID=WT_GED_ID;
+ $list = array();
+ $rows = WT_DB::prepare($sql)->execute($sql_args)->fetchAll();
foreach ($rows as $row) {
- // Switch privacy file if necessary
- if ($row->gedcom_id!=$GED_ID) {
- $GEDCOM=get_gedcom_from_id($row->gedcom_id);
- load_gedcom_settings($row->gedcom_id);
- $GED_ID=$row->gedcom_id;
- }
- $indi=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
+ $indi = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
if ($indi->canShowName()) {
- $list[]=$indi;
+ $list[] = $indi;
}
}
- // Switch privacy file if necessary
- if ($GED_ID!=WT_GED_ID) {
- $GEDCOM=WT_GEDCOM;
- load_gedcom_settings(WT_GED_ID);
- }
+
return $list;
}
/**
* get recent changes since the given julian day inclusive
*
- * @param int $jd , leave empty to include all
- * @param bool $allgeds
+ * @param integer $jd leave empty to include all
+ * @param boolean $allgeds
*
- * @return array List of XREFs of records with changes
+ * @return string[] List of XREFs of records with changes
*/
function get_recent_changes($jd=0, $allgeds=false) {
$sql="SELECT d_gid FROM `##dates` WHERE d_fact='CHAN' AND d_julianday1>=?";