feat: implement dynamic database connection service with MySQL driver and API schema endpoints
This commit is contained in:
@@ -64,6 +64,11 @@ class MySqlDriver implements DatabaseDriverInterface, SchemaDiscoveryInterface
|
||||
return $this->query("DESCRIBE `{$table}`");
|
||||
}
|
||||
|
||||
public function getTableData(string $table, int $limit = 100, int $offset = 0): array
|
||||
{
|
||||
return $this->query("SELECT * FROM `{$table}` LIMIT ? OFFSET ?", [$limit, $offset]);
|
||||
}
|
||||
|
||||
public function getForeignKeys(string $table): array
|
||||
{
|
||||
$sql = "
|
||||
|
||||
@@ -74,4 +74,12 @@ class DatabaseService
|
||||
}
|
||||
throw new \Exception("Driver does not support schema discovery.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table data.
|
||||
*/
|
||||
public function getTableData(string $table, int $limit = 100, int $offset = 0): array
|
||||
{
|
||||
return $this->getDriver()->getTableData($table, $limit, $offset);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user