SQLite: Display number of rows in database overview

This commit is contained in:
Jakub Vrana 2012-07-29 10:45:38 -07:00
parent f1153aa35a
commit e8b95f127f
3 changed files with 8 additions and 5 deletions

View file

@ -250,10 +250,12 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
} }
function table_status($name = "") { function table_status($name = "") {
global $connection;
$return = array(); $return = array();
foreach (get_rows("SELECT name AS Name, type AS Engine FROM sqlite_master WHERE type IN ('table', 'view')" . ($name != "" ? " AND name = " . q($name) : "")) as $row) { foreach (get_rows("SELECT name AS Name, type AS Engine FROM sqlite_master WHERE type IN ('table', 'view')" . ($name != "" ? " AND name = " . q($name) : "")) as $row) {
$row["Oid"] = "t"; $row["Oid"] = "t";
$row["Auto_increment"] = ""; $row["Auto_increment"] = "";
$row["Rows"] = $connection->result("SELECT COUNT(*) FROM " . idf_escape($row["Name"]));
$return[$row["Name"]] = $row; $return[$row["Name"]] = $row;
} }
foreach (get_rows("SELECT * FROM sqlite_sequence", null, "") as $row) { foreach (get_rows("SELECT * FROM sqlite_sequence", null, "") as $row) {

View file

@ -13,10 +13,10 @@ if ($_GET["script"] == "db") {
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) { foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
if ($table_status[$key] != "") { if ($table_status[$key] != "") {
$val = number_format($table_status[$key], 0, '.', lang(',')); $val = number_format($table_status[$key], 0, '.', lang(','));
json_row("$key-$id", ($key == "Rows" && $val && ( json_row("$key-$id", ($key == "Rows" && $val && $table_status["Engine"] == ($sql == "pgsql" ? "table" : "InnoDB")
$table_status["Engine"] == "InnoDB" || // MySQL InnoDB ? "~ $val"
$table_status["Engine"] == "table" // PostgreSQL table reltype : $val
) ? "~ $val" : $val)); ));
if (isset($sums[$key])) { if (isset($sums[$key])) {
// ignore innodb_file_per_table because it is not active for tables created before it was enabled // ignore innodb_file_per_table because it is not active for tables created before it was enabled
$sums[$key] += ($table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0); $sums[$key] += ($table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0);

View file

@ -1,7 +1,8 @@
Adminer 3.4.1-dev: Adminer 3.4.1-dev:
Display assigned auto_increment after clone Display assigned auto_increment after clone
SQLite: Full alter table SQLite: Full alter table
SQLite: Better editing in tables without a primary key SQLite: Better editing in tables without primary key
SQLite: Display number of rows in database overview
Adminer 3.4.0 (released 2012-06-30): Adminer 3.4.0 (released 2012-06-30):
Link to descending order Link to descending order