classe BDB et sa methode listTables()
[bazdig.git] / bazdig / sql / exec / index.php
blob6fee79f18d91708ba28b5e08c2bde409196763e7
1 <?php
2 session_start();
4 define('WARAQ_ROOT', '../../..');
5 require_once WARAQ_ROOT .'/'. 'ini.php';
7 if (!$_SESSION['db']) {
8 header('Location: '. $bazdig->get('/db')->url );
11 require "code.php";
13 $history_db = new PDO("sqlite:". $bazdig->getparam('db')->file);
14 $work_db = new PDO($_SESSION['db'], $_SESSION['db_user'], $_SESSION['db_password']);
16 SqlCode::set_db($history_db);
17 $query = new SqlCode(stripslashes($_GET['q']));
18 try {
19 $result = $query->exec($work_db);
20 } catch (Exception $e) {
21 die("ERREUR SQL:". $e->getMessage());
24 $query->save();
25 $rows = $result->fetchAll(PDO::FETCH_ASSOC);
26 $columns = columnNames($rows[0]);
28 <html>
29 <head>
30 <title><?php echo join($columns, ' '); ?></title>
31 <style type="text/css">
32 table tr td {border: solid 1px silver; padding: 10px}
33 table tr th {border: solid 1px grey; padding: 10px}
34 </style>
35 </head>
36 <body>
37 <table>
38 <?php
39 echo "<tr>";
40 foreach ($columns as $c) {
41 echo "<th>$c</th>";
43 echo "</tr>";
44 foreach ($rows as $r) {
45 echo "<tr>";
46 foreach ($r as $value) {
47 echo "<td>$value</td>";
49 echo "</tr>";
52 </table>
53 </body>
54 </html>