$err_email = "*****@*****.**";
# Retrive URL arguments
try {
    $addressnum = $_REQUEST['addressnum'];
    $format = $_REQUEST['format'];
} catch (Exception $e) {
    trigger_error("Caught Exception: " . $e->getMessage(), E_USER_ERROR);
}
# Performs the query and returns XML or JSON
try {
    $sql = "SELECT  OBJECTID, NUM_X_COORD as x_coordinate, NUM_Y_COORD as y_coordinate, \n\t\tx(transform(SETSRID(makepoint(num_x_coord ,  num_y_coord), 2264), 4326)) as longitude,\n\t\ty(transform(SETSRID(makepoint(num_x_coord ,  num_y_coord), 2264), 4326)) as latitude,\n\t\tTXT_STREET_NUMBER as house_number, CDE_STREET_DIR_PRFX as prefix, NME_STREET as street_name, \n\t\tNME_PO_CITY as postal_city, CDE_ROADWAY_TYPE as road_type, CDE_STREET_DIR_SUFF as suffix, \n\t\tTXT_ADDR_UNIT as unit, NME_CITY as city, nme_po_city as postal_city, CDE_ZIP1 as zipcode, NUM_PARENT_PARCEL as parcel_id, full_address as address  \n        FROM master_address_table WHERE objectid = ?";
    $sql = sanitizeSQL($sql);
    $pgconn = pgConnection();
    /*** fetch into an PDOStatement object ***/
    $recordSet = $pgconn->prepare($sql);
    $recordSet->bindParam(1, $addressnum);
    $recordSet->execute();
    if ($format == 'xml') {
        require_once "../inc/xml.pdo.inc.php";
        header("Content-Type: text/xml");
        echo rs2xml($recordSet);
    } elseif ($format == 'json') {
        require_once "../inc/json.pdo.inc.php";
        header("Content-Type: application/json");
        echo rs2json($recordSet);
    } else {
        trigger_error("Caught Exception: format must be xml or json.", E_USER_ERROR);
    }
} catch (Exception $e) {
    trigger_error("Caught Exception: " . $e->getMessage(), E_USER_ERROR);
}
<?php

/*--
  - Written by Toyvo Yanski <*****@*****.**>
  - Date: 2002-Jul-31
  -*/
//  This example demonstrates basic use of XML functionality. Requires PHP with
//  xslt extension (currently based on Sablotron XSLT processor).
// Change below to appropriate include path
require_once '/modules/adodb/adodb.inc.php';
require_once 'rs2xml.inc.php';
// Change below to your database type
$db = ADONewConnection('mysql');
// Change below to your settings...
$db->Connect('localhost', '', '', 'test');
// Set the query here...
$rs = $db->Execute('show tables');
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
$xml .= rs2xml($rs);
$xsl = join(file('rs2xml-debug.xsl'), '');
$arg = array('xml' => $xml, 'xsl' => $xsl);
// $params is a hash of parameters to be passed to xsl stylesheet.
$params = array();
$xh = xslt_create();
$htm = xslt_process($xh, 'arg:xml', 'arg:xsl', NULL, $arg, $params);
xslt_free($xh);
print $htm;
$rs->Close();
<?php

/*--
  - Written by Toyvo Yanski <*****@*****.**>
  - Date: 2002-Jul-31
  -*/
//  This example demonstrates basic use of rs2xml function. It outputs the xml
//  result into your browser as is.
// Change below to appropriate include path
require_once '/modules/adodb/adodb.inc.php';
require_once 'rs2xml.inc.php';
// Change below to your database type
$db = ADONewConnection('mysql');
// Change below to your settings...
$db->Connect('localhost', '', '', 'test');
// Set the query here...
$rs = $db->Execute('show tables');
$xml = rs2xml($rs);
print nl2br(htmlspecialchars($xml));
$rs->Close();
 /**
 Transforme la liste des requetes SQL en un ensemble de noeuds XML contenant le résultat.
 */
 function sql_vers_xml($requetes)
 {
     if (!is_array($requetes)) {
         return null;
         //"<erreur>Erreur, l'argument $sql n'est pas un tableau</erreur>";
         //exit;
     }
     if (sizeof($requetes) > 0) {
         $db =& ADONewConnection($this->db_type);
         // create a connection
         $connexion_result = $db->PConnect($this->db_host, $this->db_user, $this->db_pass, $this->db_name);
         // Connexion à la base
         if ($connexion_result == false) {
             $xml = "<" . "?" . "xml version='1.0' encoding='UTF-8' ?" . ">\n";
             $xml .= "<erreur>Erreur de connexion à la base de donnée</erreur>";
         } else {
             $xml = "<" . "?" . "xml version='1.0' encoding='{$this->db_encoding}' ?" . ">\n";
             $xml .= "<requetes>";
             foreach ($requetes as $key => $sql) {
                 $champs_xml = $this->requetes_sql_champs_xml[$key];
                 if ($champs_xml == null) {
                     $champs_xml = array();
                 }
                 $recordset = $db->Execute($sql);
                 if ($recordset == false) {
                     $xml .= "<erreur>" . $db->ErrorMsg() . " ({$sql})</erreur>";
                 } else {
                     $xml .= rs2xml($recordset, '', array("key" => "{$key}"), $champs_xml);
                 }
             }
             $xml .= "</requetes>\n";
         }
         $domxml = domxml_open_mem($xml);
         return $domxml->document_element();
     } else {
         return null;
     }
 }
Beispiel #5
0
$page = $_GET["page"];
$recs = $_GET["rows"];
$sidx = $_GET["sidx"];
$sord = $_GET["sord"];
if (!$sidx) {
    $sidx = 1;
}
$db = ADONewConnection($dbdriver);
$db->Connect($dbhost, $dbuser, $dbpassword, $database);
switch ($examp) {
    case 1:
        $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY " . $sidx . " " . $sord;
        $stmt = $db->Prepare($SQL);
        $rs = $db->PageExecute($stmt, $recs, $page);
        if ($rs) {
            rs2xml($rs, $page, true);
        }
        break;
    case 2:
        break;
}
function rs2xml(&$rs, $page, $id = false)
{
    if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
        header("Content-type: application/xhtml+xml;charset=utf-8");
    } else {
        header("Content-type: text/xml;charset=utf-8");
    }
    $et = ">";
    echo "<?xml version='1.0' encoding='utf-8'?{$et}\n";
    if ($page > $rs->LastPageNo()) {