Skip to content

Use a PHP object's method as the query #372

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

Merged
merged 9 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI

on: [push]
on: [push, pull_request]

permissions:
contents: read
actions: read
id-token: none

jobs:
composer:
Expand All @@ -24,7 +29,7 @@ jobs:
php_version: ${{ matrix.php }}

- name: Archive build
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
run: mkdir /tmp/github-actions/ && tar --exclude=".git" -cvf /tmp/github-actions/build.tar ./

- name: Upload build archive for test runners
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -127,7 +132,7 @@ jobs:
run: tar -xvf /tmp/github-actions/build.tar ./

- name: PHP Mess Detector
uses: php-actions/phpmd@v1
uses: php-actions/phpmd@v2
with:
php_version: ${{ matrix.php }}
path: src/
Expand Down Expand Up @@ -160,12 +165,15 @@ jobs:
remove_old_artifacts:
runs-on: ubuntu-latest

permissions:
actions: write

steps:
- name: Remove old artifacts for prior workflow runs on this repository
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
gh api "/repos/${{ github.repository }}/actions/artifacts" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
while read id
do
echo -n "Deleting artifact ID $id ... "
Expand Down
97 changes: 53 additions & 44 deletions composer.lock

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

1 change: 0 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<rule ref="Generic.Files.OneObjectStructurePerFile" />
<rule ref="Generic.Files.OneTraitPerFile" />
<rule ref="Generic.Formatting.DisallowMultipleStatements" />
<rule ref="Generic.Formatting.NoSpaceAfterCast" />
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
<rule ref="Generic.Metrics.CyclomaticComplexity" />
Expand Down
9 changes: 9 additions & 0 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Database {
/** @var array<Driver> */
protected array $driverArray;
protected Connection $currentConnectionName;
protected string $appNamespace = "\\App";

public function __construct(SettingsInterface...$connectionSettings) {
if(empty($connectionSettings)) {
Expand All @@ -36,6 +37,14 @@ public function __construct(SettingsInterface...$connectionSettings) {
$this->storeQueryCollectionFactoryFromSettings($connectionSettings);
}

public function setAppNameSpace(string $namespace):void {
if(!str_starts_with($namespace, "\\")) {
$namespace = "\\$namespace";
}

$this->appNamespace = $namespace;
}

public function insert(string $queryName, mixed...$bindings):string {
$result = $this->query($queryName, $bindings);
return $result->lastInsertId();
Expand Down
Loading