0 follower

Class Yiisoft\Yii\Debug\Api\Inspector\Database\Cycle\CycleSchemaProvider

InheritanceYiisoft\Yii\Debug\Api\Inspector\Database\Cycle\CycleSchemaProvider
ImplementsYiisoft\Yii\Debug\Api\Inspector\Database\SchemaProviderInterface

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Cycle\Database\DatabaseProviderInterface $databaseProvider )
$databaseProvider \Cycle\Database\DatabaseProviderInterface

                public function __construct(private DatabaseProviderInterface $databaseProvider)
{
}

            
getTable() public method

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,
    ];
}

            
getTables() public method

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;
}