SHARE
TWEET

Untitled

a guest Apr 27th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. //***********************************************************************//
  4.  
  5. error_reporting(E_ALL);
  6.  
  7. require("admin/config.php");
  8.  
  9. class DBObject extends PDO {
  10.    
  11.     private $engine;
  12.     private $host;
  13.     private $database;
  14.     private $user;
  15.     private $pass;
  16.    
  17.     public function __construct(){
  18.         global $pixieconfig;
  19.         $this->engine = 'mysql';
  20.         $this->host = $pixieconfig['host'];
  21.         $this->database = $pixieconfig['db'];
  22.         $this->user = $pixieconfig['user'];
  23.         $this->pass = $pixieconfig['pass'];
  24.         $dns = $this->engine.':dbname='.$this->database.";host=".$this->host;
  25.         parent::__construct( $dns, $this->user, $this->pass );
  26.     }
  27. }
  28.  
  29. $dbo = new DBObject();
  30. // catch errors
  31. $dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  32.  
  33. //****************************************************************************
  34. ?>
  35. <html>
  36. <head>
  37. <title>Database Info</title>
  38. </head>
  39. <body>
  40. <h1>Database Info</h1>
  41. <?php
  42.     $sql = "SHOW TABLES";
  43.     // for SQLite, untested..: "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
  44.     $statement = $dbo->prepare($sql);
  45.     $result = $statement->execute();
  46.    
  47.     if($result)
  48.     {
  49.         $rs = $statement->fetchAll();
  50.         echo "<ul>";
  51.         foreach($rs as $row)
  52.         {
  53.             echo "<li>{$row[0]}";
  54.            
  55.             $sql = "SHOW COLUMNS FROM ".$row[0]; // "SHOW COLUMNS FROM :tablename";
  56.             // for SQLite, untested: "PRAGMA table_info($row[0])"
  57.             $statement = $dbo->prepare($sql);
  58.             //$statement->bindParam(":tablename",$row[0]);
  59.             $result = $statement->execute();
  60.             if($result)
  61.             {
  62.                 echo "<table>
  63.                 <tr>
  64.                     <th>Field</th>
  65.                     <th>Type</th>
  66.                     <th>Null</th>
  67.                     <th>Key</th>
  68.                     <th>Default</th>
  69.                     <th>Extra</th>
  70.                 </tr>";
  71.                 $rs2 = $statement->fetchAll();
  72.                 foreach($rs2 as $row2)
  73.                 {
  74.                     echo "<tr>
  75.                         <td>{$row2['Field']}</td>
  76.                         <td>{$row2['Type']}</td>
  77.                         <td>{$row2['Null']}</td>
  78.                         <td>{$row2['Key']}</td>
  79.                         <td>{$row2['Default']}</td>
  80.                         <td>{$row2['Extra']}</td>
  81.                     </tr>";
  82.                 }
  83.                 echo "</table>";
  84.             }
  85.            
  86.             echo "</li>";
  87.         }
  88.         echo "</ul>";
  89.     }
  90.  ?>
  91. </body>
  92. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top