/includes/functions_db.php

Description

PEAR:DB specific functions file

This file implements the datastore functions necessary for PhpGedView to use an SQL database as its datastore. This file also implements array caches for the database tables. Whenever data is retrieved from the database it is stored in a cache. When a database access is requested the cache arrays are checked first before querying the database.

phpGedView: Genealogy Viewer Copyright (C) 2002 to 2007 PGV Development Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

  • version: $Id: functions_db.php 981 2007-03-21 13:24:38Z fisharebest $
Includes
require_once ('DB.php') (line 38)

PEAR:DB specific functions file

This file implements the datastore functions necessary for PhpGedView to use an SQL database as its datastore. This file also implements array caches for the database tables. Whenever data is retrieved from the database it is stored in a cache. When a database access is requested the cache arrays are checked first before querying the database.

phpGedView: Genealogy Viewer Copyright (C) 2002 to 2007 PGV Development Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

  • version: $Id: functions_db.php 981 2007-03-21 13:24:38Z fisharebest $
Constants
DB_BEGIN_TRANS = 'BEGIN' (line 50)
DB_COMMIT_TRANS = 'COMMIT' (line 51)
DB_LONGTEXT_TYPE = 'LONGTEXT' (line 49)
DB_RANDOM = 'RAND' (line 48)

Field and function definition variances between sql databases

Functions
check_for_import (line 184)

check if a gedcom has been imported into the database

this function checks the database to see if the given gedcom has been imported yet.

  • return: return true if the gedcom has been imported otherwise returns false
bool check_for_import (string $ged)
  • string $ged: the filename of the gedcom to check for import
compare_foundFacts_datestamp (line 3047)

Helper function for sorting the $found_facts array

void compare_foundFacts_datestamp ( $a,  $b)
  • $a
  • $b
dbquery (line 84)

query the database

this function will perform the given SQL query on the database

  • return: the connection result
Object &dbquery (string $sql, [boolean $show_error = true], [int $count = 0])
  • string $sql: the sql query to execture
  • boolean $show_error: whether or not to show any error messages
  • int $count: the number of records to return, 0 returns all
db_cleanup (line 163)

Clean up an item retrieved from the database

clean the slashes and convert special html characters to their entities for display and entry into form elements

  • return: the cleaned up item
mixed db_cleanup (mixed $item)
  • mixed $item: the item to cleanup
db_prep (line 137)

prepare an item to be updated in the database

add slashes and convert special chars so that it can be added to db

void db_prep (mixed $item)
  • mixed $item: an array or string to be prepared for the database
delete_fact (line 2824)
void delete_fact ( $linenum,  $pid,  $gedrec)
  • $linenum
  • $pid
  • $gedrec
delete_gedcom (line 2598)

Delete a gedcom from the database and the system

Does not delete the file from the file system

void delete_gedcom (string $ged)
  • string $ged: the filename of the gedcom to delete
find_family_record (line 211)

find the gedcom record for a family

This function first checks the $famlist cache to see if the family has already been retrieved from the database. If it hasn't been retrieved, then query the database and add it to the cache. also lookup the husb and wife so that they are in the cache

string find_family_record (string $famid, [ $gedfile = ""])
  • string $famid: the unique gedcom xref id of the family record to retrieve
  • $gedfile
find_first_person (line 566)

find and return the id of the first person in the gedcom

  • return: the gedcom xref id of the first person in the gedcom
string find_first_person ()
find_gedcom_record (line 383)

find the gedcom record

This function first checks the caches to see if the record has already been retrieved from the database. If it hasn't been retrieved, then query the database and add it to the cache.

string find_gedcom_record (string $pid, [ $gedfile = ""])
  • string $pid: the unique gedcom xref id of the record to retrieve
  • $gedfile
find_media_record (line 528)

Find a media record by its ID

void find_media_record (string $rid, [ $gedfile = ''])
  • string $rid: the record id
  • $gedfile
find_person_record (line 291)

find the gedcom record for an individual

This function first checks the $indilist cache to see if the individual has already been retrieved from the database. If it hasn't been retrieved, then query the database and add it to the cache.

string find_person_record (string $pid, [ $gedfile = ""])
  • string $pid: the unique gedcom xref id of the individual record to retrieve
  • $gedfile
find_place_list (line 1868)
void find_place_list ( $place)
  • $place
find_repo_record (line 497)

Find a repository record by its ID

void find_repo_record (string $rid, [string $gedfile = ""])
  • string $rid: the record id
  • string $gedfile: the gedcom file id
find_rin_id (line 2581)
void find_rin_id ( $rin)
  • $rin
find_source_record (line 463)

find the gedcom record for a source

This function first checks the $sourcelist cache to see if the source has already been retrieved from the database. If it hasn't been retrieved, then query the database and add it to the cache.

string find_source_record (string $sid, [ $gedfile = ""])
  • string $sid: the unique gedcom xref id of the source record to retrieve
  • $gedfile
get_alpha_fams (line 2380)

Get Families Starting with a letter

This function finds all of the families who start with the given letter

array get_alpha_fams (string $letter)
  • string $letter: The letter to search on
get_alpha_indis (line 2113)

Get Individuals Starting with a letter

This function finds all of the individuals who start with the given letter

  • return: array
  • see: indilist
array get_alpha_indis (string $letter)
  • string $letter: The letter to search on
get_asso_list (line 804)
void get_asso_list ([ $type = "all"])
  • $type
get_event_list (line 2898)

Get the list of current and upcoming events, sorted by anniversary date

This function is used by the Todays and Upcoming blocks on the Index and Portal pages. It is also used by the RSS feed.

Special note on unknown day-of-month: When the anniversary date is imprecise, the sort will pretend that the day-of-month is either tomorrow or the first day of next month. These imprecise anniversaries will sort to the head of the chosen day.

Special note on Privacy: This routine does not check the Privacy of the events in the list. That check has to be done by the routine that makes use of the event list.

void get_event_list ()
get_fam_alpha (line 2027)
void get_fam_alpha ()
get_fam_list (line 876)
void get_fam_list ()
get_faq_data (line 2807)

Retrieve the array of faqs from the DB table blocks

  • return: The array containing the FAQ items
array get_faq_data ([int $id = ''])
  • int $id: The FAQ ID to retrieven
get_indi_alpha (line 1954)

get all first letters of individual's last names

array get_indi_alpha ()
get_indi_list (line 766)
void get_indi_list ()
get_list_size (line 2657)
void get_list_size ( $list, [ $filter = ""])
  • $list
  • $filter
get_media_list (line 1895)
void get_media_list ()
get_next_id (line 2750)

get next unique id for the given table

  • return: the new id
int get_next_id (string $table, string $field)
  • string $table: the name of the table
  • string $field: the field to get the next number for
get_other_list (line 912)
void get_other_list ()
get_place_list (line 1817)

find all of the places in the hierarchy The $parent array holds the parent hierarchy of the places we want to get. The level holds the level in the hierarchy that we are at.

void get_place_list ()
get_place_parent_id (line 1795)

get place parent ID

int get_place_parent_id (array $parent, int $level)
  • array $parent
  • int $level
get_place_positions (line 1842)

get all of the place connections

array get_place_positions (array $parent, [int $level = ''])
  • array $parent
  • int $level
get_recent_changes (line 1172)

get recent changes since the given date inclusive

  • author: yalnifj
void get_recent_changes ([int $day = ""], [int $mon = ""], [int $year = ""], [ $allgeds = false])
  • int $day: the day of the month to search for, leave empty to include all
  • int $mon: the integer value for the month to search for, leave empty to include all
  • int $year: the year to search for, leave empty to include all
  • $allgeds
get_remote_id (line 2868)

get_remote_id Recieves a RFN key and returns a Stub ID if the RFN exists

  • return: Stub ID that contains the RFN number. Returns false if it didn't find anything
  • access: public
gid get_remote_id (mixed $rfn)
  • mixed $rfn: RFN number to see if it exists
get_repo_add_title_list (line 737)

get a list of all the repository titles

returns an array of all of the repositorytitles in the database.

array get_repo_add_title_list ()
get_repo_id_list (line 705)
void get_repo_id_list ()
get_repo_list (line 677)
void get_repo_list ()
get_server_list (line 2775)

get a list of remote servers

void get_server_list ()
get_source_add_title_list (line 619)

get a list of all the source titles

returns an array of all of the sourcetitles in the database.

array get_source_add_title_list ()
get_source_list (line 652)

get a list of all the sources

returns an array of all of the sources in the database.

array get_source_list ()
get_surname_fams (line 2506)

Get Families with a given surname

This function finds all of the individuals who have the given surname

  • return: array
  • see: indilist
array get_surname_fams (string $surname)
  • string $surname: The surname to search on
get_surname_indis (line 2287)

Get Individuals with a given surname

This function finds all of the individuals who have the given surname

  • return: array
  • see: indilist
array get_surname_indis (string $surname)
  • string $surname: The surname to search on
get_top_surnames (line 2711)

get the top surnames

array get_top_surnames (int $num)
  • int $num: how many surnames to return
load_families (line 241)

Load up a group of families into the cache by their ids from an array

This function is useful for optimizing pages that need to reference large sets of families without loading them up individually

void load_families (array $ids, [ $gedfile = ''])
  • array $ids: an array of ids to load up
  • $gedfile
load_people (line 332)

Load up a group of people into the cache by their ids from an array

This function is useful for optimizing pages that need to reference large sets of people without loading them up individually

void load_people (array $ids, [ $gedfile = ''])
  • array $ids: an array of ids to load up
  • $gedfile
reset_isdead (line 605)

reset the i_isdead column

This function will reset the i_isdead column with the default -1 so that all is dead status items will be recalculated.

void reset_isdead ()
search_fams (line 1266)
void search_fams ( $query, [ $allgeds = false], [ $ANDOR = "AND"], [ $allnames = false])
  • $query
  • $allgeds
  • $ANDOR
  • $allnames
search_fams_dates (line 1530)

Search the dates table for families that had events on the given day

  • return: array with all individuals that matched the query
  • author: yalnifj
array search_fams_dates ([int $day = ""], [string $month = ""], [int $year = ""], [string $fact = ""], [boolean $allgeds = false])
  • int $day: the day of the month to search for, leave empty to include all
  • string $month: the 3 letter abbr. of the month to search for, leave empty to include all
  • int $year: the year to search for, leave empty to include all
  • string $fact: the facts to include (use a comma seperated list to include multiple facts) prepend the fact with a ! to not include that fact
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
search_fams_members (line 1410)

Search the families table for individuals are part of that family either as a husband, wife or child.

  • return: array with all families that matched the query
  • author: roland-d
array search_fams_members (array $query, [boolean $allgeds = false], [string $ANDOR = "AND"], [boolean $allnames = false])
  • array $query: the query to search for as an array
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
  • string $ANDOR: setting if the sql query should be constructed with AND or OR
  • boolean $allnames: true returns all names in an array
search_fams_names (line 1340)
void search_fams_names ( $query, [ $ANDOR = "AND"], [ $allnames = false], [ $gedcnt = 1])
  • $query
  • $ANDOR
  • $allnames
  • $gedcnt
search_fams_year_range (line 1479)
void search_fams_year_range ( $startyear,  $endyear, [ $allgeds = false])
  • $startyear
  • $endyear
  • $allgeds
search_indis (line 946)

Search the database for individuals that match the query

uses a regular expression to search the gedcom records of all individuals and returns an array list of the matching individuals

  • return: array with all individuals that matched the query
  • author: yalnifj
array search_indis (string $query, [boolean $allgeds = false], [ $ANDOR = "AND"])
  • string $query: a regular expression query to search for
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
  • $ANDOR
search_indis_dates (line 1208)

Search the dates table for individuals that had events on the given day

  • return: array with all individuals that matched the query
  • author: yalnifj
array search_indis_dates ([int $day = ""], [string $month = ""], [int $year = ""], [string $fact = ""], [boolean $allgeds = false], [ $ANDOR = "AND"])
  • int $day: the day of the month to search for, leave empty to include all
  • string $month: the 3 letter abbr. of the month to search for, leave empty to include all
  • int $year: the year to search for, leave empty to include all
  • string $fact: the facts to include (use a comma seperated list to include multiple facts) prepend the fact with a ! to not include that fact
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
  • $ANDOR
search_indis_fam (line 1014)
void search_indis_fam ( $add2myindilist)
  • $add2myindilist
search_indis_names (line 1079)
void search_indis_names ( $query, [ $allgeds = false])
  • $query
  • $allgeds
search_indis_year_range (line 1042)

Search for individuals who had dates within the given year ranges

array search_indis_year_range (int $startyear, int $endyear, [ $allgeds = false])
  • int $startyear: the starting year
  • int $endyear: The ending year
  • $allgeds
search_other (line 1689)
void search_other ( $query, [ $allgeds = false], [ $type = ""], [ $ANDOR = "AND"])
  • $query
  • $allgeds
  • $type
  • $ANDOR
search_other_dates (line 1749)

Search the dates table for other records that had events on the given day

  • return: array with all individuals that matched the query
  • author: yalnifj
array search_other_dates ([ $day = ""], [ $month = ""], [ $year = ""], [ $fact = ""], [boolean $allgeds = false])
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
  • $day
  • $month
  • $year
  • $fact
search_sources (line 1592)
void search_sources ( $query, [ $allgeds = false], [ $ANDOR = "AND"])
  • $query
  • $allgeds
  • $ANDOR
search_sources_dates (line 1652)

Search the dates table for sources that had events on the given day

  • return: array with all individuals that matched the query
  • author: yalnifj
array search_sources_dates ([ $day = ""], [ $month = ""], [ $year = ""], [ $fact = ""], [boolean $allgeds = false])
  • boolean $allgeds: setting if all gedcoms should be searched, default is false
  • $day
  • $month
  • $year
  • $fact
update_isdead (line 587)

update the is_dead status in the database

this function will update the is_dead field in the individuals table with the correct value calculated by the is_dead() function. To improve import performance, the is_dead status is first set to -1 during import. The first time the is_dead status is retrieved this function is called to update the database. This makes the first request for a person slower, but will speed up all future requests.

  • return: 1 if the person is dead, 0 if living
int update_isdead (string $gid, array $indi)
  • string $gid: gedcom xref id of individual to update
  • array $indi: the $indi array struction for the individal as used in the $indilist

Documentation generated on Wed, 28 Mar 2007 09:54:17 -0600 by phpDocumentor 1.3.1