{"id":19641288,"url":"https://github.com/robindumontchaponet/reflexivecore","last_synced_at":"2026-05-10T20:50:21.370Z","repository":{"id":62550265,"uuid":"326212169","full_name":"RobinDumontChaponet/ReflexiveCore","owner":"RobinDumontChaponet","description":"[WIP] Lazy PDO connection and some enums…","archived":false,"fork":false,"pushed_at":"2022-12-11T21:34:15.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T23:36:20.950Z","etag":null,"topics":["database","pdo","php8","work-in-progress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobinDumontChaponet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-02T15:31:18.000Z","updated_at":"2022-07-28T22:00:36.000Z","dependencies_parsed_at":"2023-01-27T07:31:08.382Z","dependency_job_id":null,"html_url":"https://github.com/RobinDumontChaponet/ReflexiveCore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinDumontChaponet%2FReflexiveCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinDumontChaponet%2FReflexiveCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinDumontChaponet%2FReflexiveCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinDumontChaponet%2FReflexiveCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinDumontChaponet","download_url":"https://codeload.github.com/RobinDumontChaponet/ReflexiveCore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240947671,"owners_count":19883031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","pdo","php8","work-in-progress"],"created_at":"2024-11-11T14:08:39.814Z","updated_at":"2026-05-10T20:50:21.363Z","avatar_url":"https://github.com/RobinDumontChaponet.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReflexiveCore\n\n$$ {{∀ x ∈ X : x R x}} $$\n\nShared building blocks for the Reflexive PHP packages.\n\nThis package contains:\n\n- `Reflexive\\Core\\Database`: a lazy `PDO` wrapper that opens the connection on first real use.\n- `Reflexive\\Core\\Condition` and `Reflexive\\Core\\ConditionGroup`: abstract condition primitives used by higher-level packages.\n- `Reflexive\\Core\\Comparator` and `Reflexive\\Core\\Operator`: enums for SQL comparisons and boolean chaining.\n- `Reflexive\\Core\\Strings::quote()`: a small helper that backticks SQL identifiers.\n\n## Requirements\n\n- PHP `^8.4`\n\n## Installation\n\n```bash\ncomposer require reflexive/core\n```\n\n## Lazy database connections\n\n`Database` extends `PDO`, but it does not call the parent constructor until you actually use the connection.\nThat means you can pass a configured database object around without opening the socket immediately.\n\n```php\nuse Reflexive\\Core\\Database;\n\n$db = new Database(\n\t'mysql:host=127.0.0.1;dbname=app;charset=utf8mb4',\n\t'user',\n\t'secret',\n);\n\n// No connection yet.\n$stmt = $db-\u003eprepare('SELECT 1');\n$stmt-\u003eexecute();\n```\n\nThe class also exposes `Database::once()` to keep one lazy instance per DSN:\n\n```php\n$db = Database::once('sqlite:/tmp/app.sqlite');\n```\n\nDefault PDO options applied on connect:\n\n- `PDO::ATTR_DEFAULT_FETCH_MODE =\u003e PDO::FETCH_OBJ`\n- `PDO::ATTR_EMULATE_PREPARES =\u003e false`\n- `PDO::ATTR_PERSISTENT =\u003e false`\n- `PDO::ATTR_ERRMODE =\u003e PDO::ERRMODE_EXCEPTION`\n\n## Conditions and operators\n\nThe abstract condition API is intentionally small and is meant to be subclassed by query layers.\n\n```php\nuse Reflexive\\Core\\Comparator;\nuse Reflexive\\Core\\Operator;\n```\n\nAvailable comparators:\n\n- `EQUAL`\n- `NOTEQUAL`\n- `GREATER`\n- `LESS`\n- `GREATEROREQUAL`\n- `LESSOREQUAL`\n- `IN`\n- `BETWEEN`\n- `LIKE`\n- `NULL`\n- `NOTNULL`\n\nAvailable boolean operators:\n\n- `AND`\n- `OR`\n\n`ConditionGroup` enforces explicit chaining: once a condition has been added, the next one must be preceded by `and()` or `or()`.\n\n## Identifier quoting\n\n`Strings::quote()` wraps bare identifiers in backticks while leaving SQL functions and already-quoted names alone.\n\n```php\nuse Reflexive\\Core\\Strings;\n\nStrings::quote('users.email'); // `users`.`email`\nStrings::quote('COUNT(*)');    // COUNT(*)\n```\n\n## Scope\n\nThis package is mostly infrastructure. On its own it does not build SQL or hydrate models; those features live in:\n\n- `reflexive/query`\n- `reflexive/model`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobindumontchaponet%2Freflexivecore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobindumontchaponet%2Freflexivecore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobindumontchaponet%2Freflexivecore/lists"}