Class Yiisoft\Yii\Debug\Api\Inspector\Database\Cycle\CycleSchemaProvider
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Public Methods
Method Details
| public mixed __construct ( \ | ||
| $databaseProvider | \ |
|
public function __construct(private DatabaseProviderInterface $databaseProvider) {}
| public array getTable ( string $tableName ) | ||
| $tableName | string | |
public function getTable(string $tableName): array
{
$database = $this->databaseProvider->database();
$schema = $database->table($tableName);
// TODO: add pagination
$records = $database->select()->from($tableName)->fetchAll();
return [
'table' => $schema->getName(),
'primaryKeys' => $schema->getPrimaryKeys(),
'columns' => $this->serializeCycleColumnsSchemas($schema->getColumns()),
'records' => $records,
];
}
| public array getTables ( ) |
public function getTables(): array
{
$database = $this->databaseProvider->database();
$tableSchemas = $database->getTables();
$tables = [];
foreach ($tableSchemas as $schema) {
$records = $database->select()->from($schema->getName())->count();
$tables[] = [
'table' => $schema->getName(),
'primaryKeys' => $schema->getPrimaryKeys(),
'columns' => $this->serializeCycleColumnsSchemas($schema->getColumns()),
'records' => $records,
];
}
return $tables;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.