summaryrefslogtreecommitdiff
path: root/includes/functions/functions_db.php
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2010-06-20 22:44:44 +0000
committerfisharebest <fisharebest@gmail.com>2010-06-20 22:44:44 +0000
commit2c5db0770af76152dbdf0e21a90f690fcaf2c71e (patch)
treee261a181042076de7a9818322879a392e3d33ab6 /includes/functions/functions_db.php
parent7505c7796345b06444ad7a7462d683d107c80aab (diff)
downloadwebtrees-2c5db0770af76152dbdf0e21a90f690fcaf2c71e.tar.gz
webtrees-2c5db0770af76152dbdf0e21a90f690fcaf2c71e.tar.bz2
webtrees-2c5db0770af76152dbdf0e21a90f690fcaf2c71e.zip
Move autocomplete functions to autocomplete file
Diffstat (limited to 'includes/functions/functions_db.php')
-rw-r--r--includes/functions/functions_db.php208
1 files changed, 0 insertions, 208 deletions
diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php
index 46511a98a0..388933c42f 100644
--- a/includes/functions/functions_db.php
+++ b/includes/functions/functions_db.php
@@ -2484,212 +2484,4 @@ function update_favorites($xref_from, $xref_to, $ged_id=WT_GED_ID) {
->execute(array($xref_to, $xref_from, $ged_name))
->rowCount();
}
-////////////////////////////////////////////////////////////////////////////////
-// Autocomplete functions
-////////////////////////////////////////////////////////////////////////////////
-
-function get_autocomplete_INDI($FILTER, $ged_id=WT_GED_ID) {
- // search for ids first and request the exact id from FILTER and ids with one additional digit
- $sql=
- "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex".
- " FROM `##individuals`, `##name`".
- " WHERE (i_id=? OR i_id LIKE ?)".
- " AND i_id=n_id AND i_file=n_file AND i_file=?".
- " ORDER BY i_id";
- $rows=
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("{$FILTER}", "{$FILTER}_", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
- // if the number of rows is not zero, the input is an id and you don't need to search the names for
- if (count($rows) ==0) {
- $sql=
- "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex".
- " FROM `##individuals`, `##name`".
- " WHERE n_sort LIKE ?".
- " AND i_id=n_id AND i_file=n_file AND i_file=?".
- " ORDER BY n_sort";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
- }
- else {
- return $rows;
- }
-}
-
-function get_autocomplete_FAM($FILTER, $ids, $ged_id=WT_GED_ID) {
- $vars=array();
- if (empty($ids)) {
- //-- no match : search for FAM id
- $where = "f_id LIKE ?";
- $vars[]="%{$FILTER}%";
- } else {
- //-- search for spouses
- $qs=implode(',', array_fill(0, count($ids), '?'));
- $where = "(f_husb IN ($qs) OR f_wife IN ($qs))";
- $vars=array_merge($vars, $ids, $ids);
- }
- $sql="SELECT 'FAM' AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec, f_husb, f_wife, f_chil, f_numchil ".
- "FROM `##families` ".
- "WHERE {$where} AND f_file=?";
- $vars[]=$ged_id;
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute($vars)
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_NOTE($FILTER, $ged_id=WT_GED_ID) {
- $sql="SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec ".
- "FROM `##other` ".
- "WHERE o_gedcom LIKE ? AND o_type='NOTE' AND o_file=?";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_SOUR($FILTER, $ged_id=WT_GED_ID) {
- $sql="SELECT 'SOUR' AS type, s_id AS xref, s_file AS ged_id, s_gedcom AS gedrec ".
- "FROM `##sources` ".
- "WHERE (s_name LIKE ? OR s_id LIKE ?) AND s_file=? ORDER BY s_name";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", "{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_SOUR_TITL($FILTER, $ged_id=WT_GED_ID) {
- $sql="SELECT 'SOUR' AS type, s_id AS xref, s_file AS ged_id, s_gedcom AS gedrec ".
- "FROM `##sources` ".
- "WHERE s_name LIKE ? AND s_file=? ORDER BY s_name";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_INDI_BURI_CEME($FILTER, $ged_id=WT_GED_ID) {
- $sql=
- "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex ".
- "FROM `##individuals` ".
- "WHERE i_gedcom LIKE ? AND i_file=?";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%1 BURI%2 CEME %{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_INDI_SOUR_PAGE($FILTER, $OPTION, $ged_id=WT_GED_ID) {
- $sql="SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex ".
- "FROM `##individuals` ".
- "WHERE i_gedcom LIKE ? AND i_file=?";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("% SOUR @{$OPTION}@% PAGE %{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_FAM_SOUR_PAGE($FILTER, $OPTION, $ged_id=WT_GED_ID) {
- $sql=
- "SELECT 'FAM' AS type, f_id AS xref, f_file AS ged_id, f_gedcom AS gedrec, f_husb, f_wife, f_chil, f_numchil ".
- "FROM `##families` ".
- "WHERE f_gedcom LIKE ? AND f_file=?";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("% SOUR @{$OPTION}@% PAGE %{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_REPO($FILTER, $ged_id=WT_GED_ID) {
- $sql=
- "SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec ".
- "FROM `##other` ".
- "WHERE (o_gedcom LIKE ? OR o_id LIKE ?) AND o_file=? AND o_type='REPO'";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%1 NAME %{$FILTER}%", "{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_REPO_NAME($FILTER, $ged_id=WT_GED_ID) {
- $sql=
- "SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec ".
- "FROM `##other` ".
- "WHERE o_gedcom LIKE ? AND o_file=? AND o_type='REPO'";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%1 NAME %{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_OBJE($FILTER, $ged_id=WT_GED_ID) {
- $sql="SELECT m_media ".
- "FROM `##media` ".
- "WHERE (m_titl LIKE ? OR m_media LIKE ?) AND m_gedfile=?";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", "{$FILTER}%", $ged_id))
- ->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function get_autocomplete_SURN($FILTER, $ged_id=WT_GED_ID) {
- $sql="SELECT DISTINCT n_surname ".
- "FROM `##name` ".
- "WHERE n_surname LIKE ? AND n_file=? ORDER BY n_surname";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", $ged_id))
- ->fetchOneColumn();
-}
-
-function get_autocomplete_GIVN($FILTER, $ged_id=WT_GED_ID) {
- $sql="SELECT DISTINCT n_givn ".
- "FROM `##name` ".
- "WHERE n_givn LIKE ? AND n_file=? ORDER BY n_givn";
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", $ged_id))
- ->fetchAll();
-}
-
-function get_autocomplete_PLAC($FILTER, $ged_id=WT_GED_ID) {
- $sql=
- "select p1.p_place".
- " from `##places` p1".
- " where p1.p_place like ? and p1.p_parent_id=0 AND p1.p_file=?".
- " union ".
- "select CONCAT(p1.p_place, ', ', p2.p_place)".
- " from `##places` p1".
- " join `##places` p2 ON (p1.p_parent_id=p2.p_id AND p1.p_file=p2.p_file)".
- " where p1.p_place like ? and p2.p_parent_id=0 AND p1.p_file=?".
- " union ".
- "select CONCAT(p1.p_place, ', ', p2.p_place, ', ', p3.p_place)".
- " from `##places` p1".
- " join `##places` p2 ON (p1.p_parent_id=p2.p_id AND p1.p_file=p2.p_file)".
- " join `##places` p3 ON (p2.p_parent_id=p3.p_id AND p2.p_file=p3.p_file)".
- " where p1.p_place like ? and p3.p_parent_id=0 AND p1.p_file=?".
- " union ".
- "select CONCAT(p1.p_place, ', ', p2.p_place, ', ', p3.p_place, ', ', p4.p_place)".
- " from `##places` p1".
- " join `##places` p2 ON (p1.p_parent_id=p2.p_id AND p1.p_file=p2.p_file)".
- " join `##places` p3 ON (p2.p_parent_id=p3.p_id AND p2.p_file=p3.p_file)".
- " join `##places` p4 ON (p3.p_parent_id=p4.p_id AND p3.p_file=p4.p_file)".
- " where p1.p_place like ? and p4.p_parent_id=0 AND p1.p_file=?".
- " union ".
- "select CONCAT(p1.p_place, ', ', p2.p_place, ', ', p3.p_place, ', ', p4.p_place, ', ', p5.p_place)".
- " from `##places` p1".
- " join `##places` p2 ON (p1.p_parent_id=p2.p_id AND p1.p_file=p2.p_file)".
- " join `##places` p3 ON (p2.p_parent_id=p3.p_id AND p2.p_file=p3.p_file)".
- " join `##places` p4 ON (p3.p_parent_id=p4.p_id AND p3.p_file=p4.p_file)".
- " join `##places` p5 ON (p4.p_parent_id=p5.p_id AND p4.p_file=p5.p_file)".
- " where p1.p_place like ? and p5.p_parent_id=0 AND p1.p_file=?";
-
- return
- WT_DB::prepareLimit($sql, WT_AUTOCOMPLETE_LIMIT)
- ->execute(array("%{$FILTER}%", $ged_id, "%{$FILTER}%", $ged_id, "%{$FILTER}%", $ged_id, "%{$FILTER}%", $ged_id, "%{$FILTER}%", $ged_id))
- ->fetchOneColumn();
-}
-?>