Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'config.php';
- require 'array2xml.php';
- //get username and password
- $config = new Config();
- $user = $config->getUser();
- $pass = $config->getPass();
- //create connection object
- try {
- $dbc = new PDO('mysql:host=localhost;dbname=StudentDB',
- $user, $pass);
- echo 'Connection established <br>';
- }
- catch(PDOException $e) {
- echo "An error occured while connecting to database: "
- . $e->getMessage();
- }
- $sql = $dbc->query('SELECT * FROM student');
- $result = $sql->fetchALL(PDO::FETCH_CLASS);
- echo "<pre>" . print_r($result, true) . "<pre/>";
- echo "<br>";
- echo "<br>";
- //create object of class capable of conversion
- $convert = new Array2XML();
- $xml = $convert::createXML("Student", $result);
- $xmlstring = $xml->saveXML();
- echo "<pre>" . $xmlstring . "<pre/>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement