- } else {
- $sSQL = 'select px.postcode from placex px join place_addressline pa ';
- }
- $sSQL .= 'on px.place_id = pa.address_place_id ';
- $sSQL .= 'where pa.cached_rank_address in (5,11) ';
- $sSQL .= 'and pa.place_id in (select place_id from place_addressline where address_place_id in ('.substr($aRow['place_ids'], 1, -1).')) ';
- $sSQL .= 'group by postcode order by count(*) desc limit 1';
- $sRes = $oDB->getOne($sSQL);
- if (PEAR::IsError($sRes)) fail(pg_last_error($oDB->connection));
- if ($aCMDResult['output-all-postcodes']) {
+ $sSQL .= 'on px.place_id = pa.address_place_id ';
+ $sSQL .= 'where pa.cached_rank_address in (5,11) ';
+ $sSQL .= 'and pa.place_id in (select place_id from place_addressline where address_place_id in (:first_place_id)) ';
+ $sSQL .= 'group by postcode order by count(*) desc limit 1';
+ $sRes = $oDB->getOne($sSQL, array('first_place_id' => substr($aRow['place_ids'], 1, -1)));
+