RecordSet::getSurnameChk - jcobban/Genealogy GitHub Wiki

$recordSet->getSurnameChk($value)

Up: class RecordSet

This is a shared utility method which generates the complicated expression for performing a loose comparison of a surname. Among other tests: if the instance of class Surname for the specified surname has a regular expression pattern specified, then this regular expression is used, otherwise the SQL SOUNDEX function is used for the loose comparison.

This method can only be called for an object which contains fields named 'Surname' and 'SoundsLike', or 'Soundex',for example class Person, class Surname, and class Name tables. It can be called from the getWhere method of a class-specific extension of RecordSet.

The parameters for this method are:

parameter description
$table The table being searched. Note that if this specifies 'Names', or its internal version 'tblNX', the search is actually done using the fields in the associated instance of class Surname.
$value The string value used for the comparison.

This returns a string containing a fragment of an SQL expression that can be substituted into a MySQL WHERE clause. For example:

$recordset->getSurnameChk('Person','Smith') returns "tblIR.Surname REGEXP '^sm[eiy]*th?"

$recordset->getSurnameChk('Names','Newman') returns "(tblNR.SoundsLike=LEFT(SOUNDEX('Newman')) OR tblNR.SoundsLike=LEFT(SOUNDEX('Newmans')))"

Next: $recordSet->getLastSqlCmd()