Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customization db group #736

Closed
wants to merge 3 commits into from
Closed

Customization db group #736

wants to merge 3 commits into from

Conversation

arashsaffari
Copy link
Contributor

This modification is made to add the capability of changing the name of the database connection. #727

Please note that the variable "DBGroup" cannot be changed in the "initialize()" function. It needs to be changed in the "__construct()" function.

@datamweb datamweb marked this pull request as draft May 12, 2023 01:10
@datamweb datamweb added GPG-Signing needed Pull requests that need GPG-Signing new feature PRs for new features tests needed Pull requests that need tests labels May 12, 2023
@kenjis
Copy link
Member

kenjis commented May 12, 2023

You signed only one commit, but we need you to sign all your commits.

Don't use git merge. Use git rebase instead.

@kenjis
Copy link
Member

kenjis commented May 12, 2023

Read this: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md

And if you don't know git well, it may be better to create new another PR.

@datamweb
Copy link
Collaborator

@arashsaffari , first of all I want to make sure which of the following:
Execute command:

git config --global commit.gpgsign true

Then run the following command:

git config --global user.signingkey 5FE32B838BA49CD5

The above causes all commits to be signed automatically from now on.

git fetch upstream
git switch develop
git merge upstream/develop
git switch customization_db_group
git branch -m customization_db_group customization_db_group.bk1
git switch -c customization_db_group develop
code .

After that, change src/Config/Auth.php and src/Models/BaseModel.php and run:

composer cs-fix
git add .
git commit -m "feat: add `DBGroup` for customization db group"
git push -f origin customization_db_group

@datamweb
Copy link
Collaborator

datamweb commented May 13, 2023

@arashsaffari I tried to implement this feature in the branch below. If you find the time to test it, please let us know.

https://github.com/datamweb/shield/tree/add_customization_db_group

Edit your composer.json:

--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,8 @@
     "require": {
         "php": "^7.4 || ^8.0",
         "codeigniter4/framework": "^4.0",
-        "codeigniter4/shield": "^1.0@beta"
+        "codeigniter4/shield": "dev-add_customization_db_group"
     },
+    "minimum-stability": "dev",
+    "prefer-stable": true,
+    "repositories": [
+        {
+            "type": "vcs",
+            "url": "https://github.com/datamweb/shield.git"
+        }
+    ],
 }

Run:

composer update

Add custom database connection in app/Config/Database.php:

    /**
     * The my custom database connection.
     */
    public array $myDbGroup= [
        'DSN'      => '',
        'hostname' => 'localhost',
        'username' => 'rootxxx',
        'password' => 'xxx',
        'database' => 'xxx',
        'DBDriver' => 'MySQLi',
        'DBPrefix' => '',
        'pConnect' => false,
        'DBDebug'  => true,
        'charset'  => 'utf8',
        'DBCollat' => 'utf8_general_ci',
        'swapPre'  => '',
        'encrypt'  => false,
        'compress' => false,
        'strictOn' => false,
        'failover' => [],
        'port'     => 3306,
    ];

Edit your Auth.php:

-public $dbGroupName;
+public $dbGroupName = 'myDbGroup';

@kenjis
Copy link
Member

kenjis commented May 14, 2023

@arashsaffari arashsaffari marked this pull request as ready for review May 14, 2023 23:42
@datamweb
Copy link
Collaborator

The first commit is not signed.

Screenshot 2023-05-15 174323

If you don't know git well, it may be better to create new another PR(pull request).

@arashsaffari arashsaffari closed this by deleting the head repository May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GPG-Signing needed Pull requests that need GPG-Signing new feature PRs for new features tests needed Pull requests that need tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants