Skip to content

Commit

Permalink
phpcs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skyminds committed Mar 17, 2024
2 parents 97782ca + 32d9403 commit 9634a23
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 9 deletions.
Empty file.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test

on: [push]

concurrency: production_environment

jobs:
test:
runs-on: ubuntu-latest

name: Check code style and run tests

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install PHP dependencies (composer)
run: composer install

- name: Check code style
run: composer phpcs
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/vendor/
composer.lock
.idea
*.tar.gz
*.zip
*.code-workspace
# Ignore *.sql except on the src/create_catalog_sql directory
*.sql
!src/create_catalog_sql/*.sql
!src/create_catalog_sql/*.sql
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# catalogs-php
A PHP framework to talk to Catalogs. Part of the [CloudFest 2024 Hackathon](https://hackathon.cloudfest.com/project/integrating-mariadb-catalogs-with-php-platforms/).

# Useage
# Installation

Include the catalog-php with composer:

composer require mariadb/catalogs-php
```bash
composer require mariadb/catalogs-php:dev-main
```

Include autoloader in your project.

```php
<?php require_once('vendor/autoload.php');
```

105 changes: 105 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function create(string $catName): int
throw new Exception('Catalog name already exists.');
}

$root_privileges = $this->connection->query("SELECT * FROM mysql.global_priv WHERE User='{$this->dbUser}' AND Host='%';");
$rootPrivileges = $this->connection->query("SELECT * FROM mysql.global_priv WHERE User='{$this->dbUser}' AND Host='%';");

$scripts = [
'src/create_catalog_sql/mysql_system_tables.sql',
Expand Down Expand Up @@ -121,9 +121,12 @@ public function create(string $catName): int
$this->connection->exec($content);
}

if ($root_privileges->rowCount() > 0) {
foreach ($root_privileges as $privilege) {
$this->connection->exec("INSERT INTO mysql.global_priv VALUES ('{$privilege['Host']}', '{$privilege['User']}', '{$privilege['Priv']}');");
if ($rootPrivileges->rowCount() > 0) {
foreach ($rootPrivileges as $privilege) {
$host = $privilege['Host'];
$user = $privilege['User'];
$priv = $privilege['Priv'];
$this->connection->exec("INSERT INTO mysql.global_priv VALUES ('{$host}', '{$user}', '{$priv}');");
}
}

Expand Down Expand Up @@ -203,7 +206,7 @@ public function drop(string $catName): bool
$this->connection->exec('DROP CATALOG '.$catName);
} catch (\PDOException $e) {
throw new \Exception('Error dropping catalog: '.$e->getMessage());
}//end try
}

return true;

Expand Down

0 comments on commit 9634a23

Please sign in to comment.