method dbSize documentation in bbn\Db\Languages\Pgsql
Gets the size of a database
function(string $database = '', string $type = '')
{
if ($database && ($this->getCurrent() !== $database)) {
return $this->newInstance(
array_merge($this->cfg, ['db' => $database])
)
->dbSize($database, $type);
}
$size = 0;
if ($tables = $this->getTables()) {
if ($type === 'data') {
$function = "pg_relation_size";
}
elseif ($type === 'index') {
$function = "pg_indexes_size";
}
else {
$function = "pg_total_relation_size";
}
$query = "SELECT ";
$args = [];
foreach ($tables as $table) {
$query .= "$function(?), ";
$args[] = $table;
}
$table_sizes = $this->getRow(trim($query, ', '), ...$args);
foreach ($table_sizes as $table_size) {
$size += $table_size;
}
}
return $size;
}
Gets the size of a database BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions