-
Notifications
You must be signed in to change notification settings - Fork 8
Unify SELECT / Collection under PostQueryInterface (replaces #87) #89
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
Changes from all commits
8acc97b
0b5cb4c
fa84611
86ea8c5
06499a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,11 @@ | |
| * - `get*` — SELECT queries; execute and return the result set or a | ||
| * derivation of it ({@see self::getRow()}, {@see self::getRowList()}, | ||
| * {@see self::getCount()}, {@see self::getPages()}). | ||
| * - `exec*` — DML queries (INSERT / UPDATE / DELETE); execute and either | ||
| * return nothing ({@see self::exec()}) or return a typed result | ||
| * built from the post-execution PDO state | ||
| * ({@see self::execPostQuery()}). | ||
| * - `exec*` — execute and build a typed result. {@see self::exec()} runs a | ||
| * DML statement without reading a result. | ||
| * {@see self::execPostQuery()} dispatches through the user-defined | ||
| * {@see PostQueryInterface} factory for either SELECT (hydrated | ||
| * rows available on the context) or DML (post-execution PDO state). | ||
| */ | ||
| interface SqlQueryInterface | ||
| { | ||
|
|
@@ -55,23 +56,30 @@ public function getRowList(string $sqlId, array $values = [], FetchInterface|nul | |
| public function exec(string $sqlId, array $values = [], FetchInterface|null $fetch = null): void; | ||
|
|
||
| /** | ||
| * Execute a DML statement and build a result through the given PostQuery class. | ||
| * Execute a SQL statement and build a result through the given PostQuery class. | ||
| * | ||
| * The framework calls `{$postQueryClass}::fromContext($context)` after | ||
| * executing the SQL. Each result class owns its own construction logic, so | ||
| * the caller's return-type declaration is what selects behaviour (count only, | ||
| * count + last insert id, etc.). When the SQL file contains multiple | ||
| * count + last insert id, a typed collection wrapper, etc.). For SELECT | ||
| * statements the rows are fetched and exposed on the context's `$rows` | ||
| * property — shape is determined by the supplied `$fetch` strategy (entity | ||
| * instances for an entity-bound fetch, associative arrays for `FetchAssoc`), | ||
| * or associative arrays when `$fetch` is null. For DML statements no fetch | ||
| * happens and `$rows` is `[]`. When the SQL file contains multiple | ||
| * statements, the result reflects the last executed statement only. | ||
| * | ||
| * @param array<string, mixed> $values | ||
| * @param class-string<T> $postQueryClass | ||
| * @param FetchInterface|null $fetch Strategy used to hydrate SELECT rows. Pass | ||
| * null for DML or to receive associative arrays. | ||
| * | ||
| * @return T | ||
| * | ||
| * @template T of PostQueryInterface | ||
| * @psalm-taint-escape sql | ||
| */ | ||
| public function execPostQuery(string $sqlId, array $values, string $postQueryClass): PostQueryInterface; | ||
| public function execPostQuery(string $sqlId, array $values, string $postQueryClass, FetchInterface|null $fetch = null): PostQueryInterface; | ||
|
Comment on lines
72
to
+82
|
||
|
|
||
| /** | ||
| * Return the total row count for a SELECT. Used as the pagination denominator. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.