//$aPlaceIDs is an array with key: placeID and value: tiger-housenumber, if found, else -1
if (sizeof($aPlaceIDs) == 0) return array();
- $sLanguagePrefArraySQL = "ARRAY[".join(',', array_map("getDBQuoted", $this->aLangPrefOrder))."]";
+ $sLanguagePrefArraySQL = getArraySQL(
+ array_map("getDBQuoted",
+ $this->aLangPrefOrder)
+ );
// Get the details for display (is this a redundant extra step?)
$sPlaceIDs = join(',', array_keys($aPlaceIDs));
if (!$this->sQuery && !$this->aStructuredQuery) return array();
$sNormQuery = $this->normTerm($this->sQuery);
- $sLanguagePrefArraySQL = "ARRAY[".join(',', array_map("getDBQuoted", $this->aLangPrefOrder))."]";
+ $sLanguagePrefArraySQL = getArraySQL(
+ array_map("getDBQuoted",
+ $this->aLangPrefOrder)
+ );
$sCountryCodesSQL = false;
if ($this->aCountryCodes) {
$sCountryCodesSQL = join(',', array_map('addQuotes', $this->aCountryCodes));
return (bool) $this->sHouseNumber;
}
- public function poiTable()
+ private function poiTable()
{
return 'place_classtype_'.$this->sClass.'_'.$this->sType;
}
- public function addressArraySQL()
- {
- return 'ARRAY['.join(',', $this->aAddress).']';
- }
- public function nameArraySQL()
- {
- return 'ARRAY['.join(',', $this->aName).']';
- }
-
public function countryCodeSQL($sVar, $sCountryList)
{
if ($this->sCountryCode) {
$sSQL .= ', search_name s ';
$sSQL .= 'WHERE s.place_id = p.parent_place_id ';
$sSQL .= 'AND array_cat(s.nameaddress_vector, s.name_vector)';
- $sSQL .= ' @> '.$this->addressArraySQL().' AND ';
+ $sSQL .= ' @> '.getArraySQL($this->aAddress).' AND ';
} else {
$sSQL .= 'WHERE ';
}
}
if (sizeof($this->aName)) {
- $aTerms[] = 'name_vector @> '.$this->nameArraySQL();
+ $aTerms[] = 'name_vector @> '.getArraySQL($this->aName);
}
if (sizeof($this->aAddress)) {
// For infrequent name terms disable index usage for address
&& $aWordFrequencyScores[$this->aName[reset($this->aName)]]
< CONST_Search_NameOnlySearchFrequencyThreshold
) {
- $aTerms[] = 'array_cat(nameaddress_vector,ARRAY[]::integer[]) @> '.$this->addressArraySQL();
+ $aTerms[] = 'array_cat(nameaddress_vector,ARRAY[]::integer[]) @> '.getArraySQL($this->aAddress);
} else {
- $aTerms[] = 'nameaddress_vector @> '.$this->addressArraySQL();
+ $aTerms[] = 'nameaddress_vector @> '.getArraySQL($this->aAddress);
}
}
if (sizeof($this->aFullNameAddress)) {
$sExactMatchSQL = ' ( ';
- $sExactMatchSQL .= ' SELECT count(*) FROM ( ';
- $sExactMatchSQL .= ' SELECT unnest(ARRAY['.join($this->aFullNameAddress, ",").']) ';
- $sExactMatchSQL .= ' INTERSECT ';
- $sExactMatchSQL .= ' SELECT unnest(nameaddress_vector)';
- $sExactMatchSQL .= ' ) s';
+ $sExactMatchSQL .= ' SELECT count(*) FROM ( ';
+ $sExactMatchSQL .= ' SELECT unnest('.getArraySQL($this->aFullNameAddress).')';
+ $sExactMatchSQL .= ' INTERSECT ';
+ $sExactMatchSQL .= ' SELECT unnest(nameaddress_vector)';
+ $sExactMatchSQL .= ' ) s';
$sExactMatchSQL .= ') as exactmatch';
$aOrder[] = 'exactmatch DESC';
} else {