From 294e0a0b311e5f03167c5c58202d4ab95af6ade6 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 17 Mar 2024 15:46:12 +0100 Subject: [PATCH 1/5] solve phpcs issues --- src/Catalog.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Catalog.php b/src/Catalog.php index efcb25e..dba0288 100644 --- a/src/Catalog.php +++ b/src/Catalog.php @@ -48,14 +48,15 @@ public function __construct( protected string $dbUser='root', protected string $dbPass='', protected ?array $dbOptions=null, - protected ?\PDO $pdo = null + protected ?\PDO $pdo=null ) { // Connect. try { - if($pdo !== null) { + if ($pdo !== null) { $this->connection = $pdo; return; } + // Corrected to use the updated parameter names. $this->connection = new \PDO( "mysql:host=$dbHost;port=$dbPort", @@ -79,6 +80,7 @@ public function __construct( } + /** * Create a new catalog * From 80bc18cb0f2142dbb86c95d66ba30e7805ebf11c Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 17 Mar 2024 15:48:10 +0100 Subject: [PATCH 2/5] formatting --- src/Catalog.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Catalog.php b/src/Catalog.php index dba0288..ac08dfd 100644 --- a/src/Catalog.php +++ b/src/Catalog.php @@ -263,6 +263,7 @@ public function createAdminUserForCatalog( $this->connection->prepare( "CREATE USER ?@? IDENTIFIED BY ?;" )->execute([$userName, $authHost, $password]); + $this->connection->prepare( "GRANT ALL PRIVILEGES ON `%`.* TO ?@? IDENTIFIED BY ? WITH GRANT OPTION;" )->execute([$userName, $authHost, $password]); From 606c5af299e269bfcf1c9dcb23c92042765473ab Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 17 Mar 2024 15:50:57 +0100 Subject: [PATCH 3/5] style fixes --- src/Catalog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Catalog.php b/src/Catalog.php index ac08dfd..317fb84 100644 --- a/src/Catalog.php +++ b/src/Catalog.php @@ -263,7 +263,7 @@ public function createAdminUserForCatalog( $this->connection->prepare( "CREATE USER ?@? IDENTIFIED BY ?;" )->execute([$userName, $authHost, $password]); - + $this->connection->prepare( "GRANT ALL PRIVILEGES ON `%`.* TO ?@? IDENTIFIED BY ? WITH GRANT OPTION;" )->execute([$userName, $authHost, $password]); From ffce63839d71074f5a33a898e9c9b0c003b9e6bd Mon Sep 17 00:00:00 2001 From: Florian Blaser Date: Sun, 17 Mar 2024 16:06:07 +0100 Subject: [PATCH 4/5] :recycle: refactor method name show => list --- src/Catalog.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Catalog.php b/src/Catalog.php index 317fb84..61d624f 100644 --- a/src/Catalog.php +++ b/src/Catalog.php @@ -91,7 +91,7 @@ public function __construct( public function create(string $catName): int { // Check if the Catalog name is valid. - if (in_array($catName, array_keys($this->show())) === true) { + if (in_array($catName, array_keys($this->list())) === true) { throw new Exception('Catalog name already exists.'); } @@ -162,7 +162,7 @@ public function getPort(string $catName): int * * @return int[] Named array with cat name and port. */ - public function show(): array + public function list(): array { $catalogs = []; $results = $this->connection->query('SHOW CATALOGS'); From 28538c7ce8635c7eab60cf95d46ebb3413b6a05b Mon Sep 17 00:00:00 2001 From: David Beja Date: Sun, 17 Mar 2024 16:14:15 +0100 Subject: [PATCH 5/5] Update examples.md with new list method --- examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples.md b/examples.md index 3286ac8..b5ee2f2 100644 --- a/examples.md +++ b/examples.md @@ -17,7 +17,7 @@ $catalog->create('catalog_name'); ## Return a list of all existing catalogs ```php -$catalogs = $catalog->show(); +$catalogs = $catalog->list(); /* Returns an array of catalogs on MariaDB: Array