0 follower

Class Yiisoft\Yii\Debug\Api\Inspector\Database\Db\DbSchemaProvider

InheritanceYiisoft\Yii\Debug\Api\Inspector\Database\Db\DbSchemaProvider
ImplementsYiisoft\Yii\Debug\Api\Inspector\Database\SchemaProviderInterface

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Yiisoft\Db\Connection\ConnectionInterface $db )
$db \Yiisoft\Db\Connection\ConnectionInterface

                public function __construct(private ConnectionInterface $db)
{
}

            
getTable() public method

public array getTable ( string $tableName )
$tableName string

                public function getTable(string $tableName): array
{
    /** @var TableSchemaInterface[] $tableSchemas */
    $schema = $this->db->getSchema()->getTableSchema($tableName);
    $records = (new Query($this->db))->from($schema->getName())->all();
    $data = [];
    // TODO: add pagination
    foreach ($records as $r => $record) {
        foreach ($record as $n => $attribute) {
            $data[$r][$n] = $attribute;
        }
    }
    return [
        'table' => $schema->getName(),
        'primaryKeys' => $schema->getPrimaryKey(),
        'columns' => $this->serializeARColumnsSchemas($schema->getColumns()),
        'records' => $data,
    ];
}

            
getTables() public method

public array getTables ( )

                public function getTables(): array
{
    $quoter = $this->db->getQuoter();
    /** @var TableSchemaInterface[] $tableSchemas */
    $tableSchemas = $this->db->getSchema()->getTableSchemas();
    $tables = [];
    foreach ($tableSchemas as $schema) {
        $tables[] = [
            'table' => $quoter->unquoteSimpleTableName($schema->getName()),
            'primaryKeys' => $schema->getPrimaryKey(),
            'columns' => $this->serializeARColumnsSchemas($schema->getColumns()),
            'records' => (new Query($this->db))->from($schema->getName())->count(),
        ];
    }
    return $tables;
}