PHP_XML のバックアップ(No.1) - アールメカブ

アールメカブ


PHP_XML のバックアップ(No.1)


sudo pear install XML_Query2XML ## --alldeps を忘れた
[sudo] password for ishida: 
Did not download optional dependencies: pear/Net_LDAP2, 
  pear/MDB2, pear/I18N_UnicodeString, use --alldeps to download 
   automatically
pear/XML_Query2XML can optionally use package "pear/Net_LDAP2"
pear/XML_Query2XML can optionally use package "pear/MDB2"
pear/XML_Query2XML can optionally use package  
  "pear/I18N_UnicodeString"
downloading XML_Query2XML-1.7.1.tgz ...
Starting to download XML_Query2XML-1.7.1.tgz (169,218 bytes)
.....................................done: 169,218 bytes
install ok: channel://pear.php.net/XML_Query2XML-1.7.1
ishida@app:~/public_html$ sudo pear install --alldeps MDB2
downloading MDB2-2.4.1.tgz ...
Starting to download MDB2-2.4.1.tgz (119,790 bytes)
..........................done: 119,790 bytes
install ok: channel://pear.php.net/MDB2-2.4.1
MDB2: Optional feature fbsql available (Frontbase SQL driver for MDB2)
MDB2: Optional feature ibase available (Interbase/Firebird driver for MDB2)
MDB2: Optional feature mysql available (MySQL driver for MDB2)
MDB2: Optional feature mysqli available (MySQLi driver for MDB2)
MDB2: Optional feature mssql available (MS SQL Server driver for MDB2)
MDB2: Optional feature oci8 available (Oracle driver for MDB2)
MDB2: Optional feature pgsql available (PostgreSQL driver for MDB2)
MDB2: Optional feature querysim available (Querysim driver for MDB2)
MDB2: Optional feature sqlite available (SQLite2 driver for MDB2)
MDB2: To install optional features use "pear install  
     pear/MDB2#featurename"
ishida@app:~/public_html$ sudo pear install --alldeps MDB2#mysql
Skipping package "pear/MDB2", already installed as version 2.4.1
downloading MDB2_Driver_mysql-1.4.1.tgz ...
Starting to download MDB2_Driver_mysql-1.4.1.tgz (36,481 bytes)
..........done: 36,481 bytes
install ok: channel://pear.php.net/MDB2_Driver_mysql-1.4.1
ishida@app:~/public_html$ sudo pear install --alldeps MDB2#mysqli
Skipping package "pear/MDB2", already installed as version 2.4.1
downloading MDB2_Driver_mysqli-1.4.1.tgz ...
Starting to download MDB2_Driver_mysqli-1.4.1.tgz (38,064 bytes)
..........done: 38,064 bytes
install ok: channel://pear.php.net/MDB2_Driver_mysqli-1.4.1
<?php
// include required files
include 'XML/Query2XML.php';
include 'MDB2.php';

try {
   // initialize Query2XML object
   $q2x =  
        XML_Query2XML::factory(MDB2::factory(
            'mysql://USER_NAME:PASSWORD@localhost/DB_NAME'));
   // generate SQL query
   // get results as XML
   $sql = "SELECT * FROM users";

$dom = $q2x->getXML( $sql,
   array(
     'rootTag' => 'myroot',
     'rowTag' => 'myrow',
     'idColumn' => 'id',
     'elements' => array('id','password',  'name', 'email'),
     'encoder' => false
   )
 );

 header('Content-Type: application/xml');
$xml->formatOutput = true;
print $dom->saveXML();
} catch (Exception $e) {
   echo $e->getMessage();
}
?>

ここここなどを参考にする