Exemplo n.º 1
0
}
$qtext = $qtext . " FROM {$query_table}";
if ($query_where != "") {
    $qtext = $qtext . " WHERE {$query_where}";
}
if ($query_order != "") {
    $qtext = $qtext . " ORDER BY {$query_order}";
}
if ($query_limit != "") {
    $qtext = $qtext . " LIMIT {$query_limit}";
}
$qtext = $qtext . ";";
//echo $post;
echo $qtext . "\n";
//echo $post . "\n" . $qtext . "\n";
$pgc = postgis_connect();
@($result = pg_query($pgc, $qtext));
pg_close($pgc);
if (!$result) {
    echo '<?xml version="1.0"?>
  <query_result result="ERROR" reason="Error performing query: Query failed in database."/>';
    die;
}
$xml = new SimpleXMLElement("<query_result/>");
$xml->addAttribute("table", pg_field_table($result, 0));
$xml->addAttribute("token", $query_token);
if ($query_limit == "0") {
    $xml->addAttribute("result", "FIELDS");
    for ($i = 0; $i < pg_num_fields($result); $i++) {
        $field = $xml->addChild("field");
        $field->addAttribute("name", pg_field_name($result, $i));
Exemplo n.º 2
0
function getLayersForTokenWithPROJ4($token, $where = NULL)
{
    $pgc = postgis_connect();
    global $postgis_table_layers, $postgis_table_sessions;
    if ($where != NULL) {
        $array = postgis_query("SELECT l.* FROM {$postgis_table_layers} AS l LEFT OUTER JOIN {$postgis_table_sessions} AS s ON l.owner=s.user_id WHERE (s.token='{$token}' OR l.owner = 0) AND {$where};", $pgc);
    } else {
        $array = postgis_query("SELECT l.* FROM {$postgis_table_layers} AS l LEFT OUTER JOIN {$postgis_table_sessions} AS s ON l.owner=s.user_id WHERE (s.token='{$token}' OR l.owner = 0);", $pgc);
    }
    for ($i = 1; $i < count($array); $i++) {
        $arr = postgis_query("SELECT proj4text as proj4 FROM spatial_ref_sys as s,geometry_columns as g WHERE g.f_table_name='" . $array[$i]['name'] . "' AND s.srid=g.srid;", $pgc);
        if (count($arr) > 1) {
            $array[$i]['PROJ4'] = $arr[1]['proj4'];
        }
    }
    pg_close($pgc);
    return $array;
}