Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //***********************************************************************//
- error_reporting(E_ALL);
- require("admin/config.php");
- class DBObject extends PDO {
- private $engine;
- private $host;
- private $database;
- private $user;
- private $pass;
- public function __construct(){
- global $pixieconfig;
- $this->engine = 'mysql';
- $this->host = $pixieconfig['host'];
- $this->database = $pixieconfig['db'];
- $this->user = $pixieconfig['user'];
- $this->pass = $pixieconfig['pass'];
- $dns = $this->engine.':dbname='.$this->database.";host=".$this->host;
- parent::__construct( $dns, $this->user, $this->pass );
- }
- }
- $dbo = new DBObject();
- // catch errors
- $dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
- //****************************************************************************
- ?>
- <html>
- <head>
- <title>Database Info</title>
- </head>
- <body>
- <h1>Database Info</h1>
- <?php
- $sql = "SHOW TABLES";
- // for SQLite, untested..: "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
- $statement = $dbo->prepare($sql);
- $result = $statement->execute();
- if($result)
- {
- $rs = $statement->fetchAll();
- echo "<ul>";
- foreach($rs as $row)
- {
- echo "<li>{$row[0]}";
- $sql = "SHOW COLUMNS FROM ".$row[0]; // "SHOW COLUMNS FROM :tablename";
- // for SQLite, untested: "PRAGMA table_info($row[0])"
- $statement = $dbo->prepare($sql);
- //$statement->bindParam(":tablename",$row[0]);
- $result = $statement->execute();
- if($result)
- {
- echo "<table>
- <tr>
- <th>Field</th>
- <th>Type</th>
- <th>Null</th>
- <th>Key</th>
- <th>Default</th>
- <th>Extra</th>
- </tr>";
- $rs2 = $statement->fetchAll();
- foreach($rs2 as $row2)
- {
- echo "<tr>
- <td>{$row2['Field']}</td>
- <td>{$row2['Type']}</td>
- <td>{$row2['Null']}</td>
- <td>{$row2['Key']}</td>
- <td>{$row2['Default']}</td>
- <td>{$row2['Extra']}</td>
- </tr>";
- }
- echo "</table>";
- }
- echo "</li>";
- }
- echo "</ul>";
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment