<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "fkeyid")
    $pp_id = $paramValue;
  else if ($paramName == "pattern")
    $pattern = trim($paramValue);
}

$dal = new DAL();

$sql = "SELECT SU.id, SU.name AS hint " .
       "FROM projectparcelspatialunit PS, spatialunit SU " .
       "WHERE PS.projectparcel_id = $pp_id AND SU.id = PS.spatialunit_id " .
       "AND SU.spatialunitype_id = 1 AND SU.name LIKE '%$pattern%' " ;
$result = $dal->query($sql);

echo json_encode ($result);

?>