2010-08-03 21:06:56 +02:00
|
|
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
|
|
|
|
|
|
|
<h1>Database Reflection | dibi</h1>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
2015-01-13 16:27:01 +01:00
|
|
|
require __DIR__ . '/../src/loader.php';
|
2010-08-03 21:06:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
dibi::connect(array(
|
2015-06-19 03:11:36 +02:00
|
|
|
'driver' => 'sqlite3',
|
2012-10-18 23:00:12 +02:00
|
|
|
'database' => 'data/sample.s3db',
|
2010-08-03 21:06:56 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
// retrieve database reflection
|
|
|
|
$database = dibi::getDatabaseInfo();
|
|
|
|
|
|
|
|
echo "<h2>Database '{$database->name}'</h2>\n";
|
|
|
|
echo "<ul>\n";
|
|
|
|
foreach ($database->getTables() as $table) {
|
|
|
|
echo '<li>', ($table->view ? 'view' : 'table') . " $table->name</li>\n";
|
|
|
|
}
|
|
|
|
echo "</ul>\n";
|
|
|
|
|
|
|
|
|
|
|
|
// table reflection
|
|
|
|
$table = $database->getTable('products');
|
|
|
|
|
|
|
|
echo "<h2>Table '{$table->name}'</h2>\n";
|
|
|
|
|
|
|
|
echo "Columns\n";
|
|
|
|
echo "<ul>\n";
|
|
|
|
foreach ($table->getColumns() as $column) {
|
|
|
|
echo "<li>{$column->name} <i>{$column->nativeType}</i> <code>{$column->default}</code></li>\n";
|
|
|
|
}
|
|
|
|
echo "</ul>\n";
|
|
|
|
|
|
|
|
|
2015-06-19 03:11:36 +02:00
|
|
|
echo 'Indexes';
|
2010-08-03 21:06:56 +02:00
|
|
|
echo "<ul>\n";
|
|
|
|
foreach ($table->getIndexes() as $index) {
|
|
|
|
echo "<li>{$index->name} " . ($index->primary ? 'primary ' : '') . ($index->unique ? 'unique' : '') . ' (';
|
|
|
|
foreach ($index->getColumns() as $column) {
|
|
|
|
echo "$column->name, ";
|
|
|
|
}
|
|
|
|
echo ")</li>\n";
|
|
|
|
}
|
|
|
|
echo "</ul>\n";
|