classCteRows
final class CteRows
Public API: explicitly declared with
@visibility public.Serializes arbitrary fixture rows through the public ValueRenderer contract into a table CTE.
$rows = new \ZtdQuery\Platform\MySql\Rewrite\Transformer\Shadow\CteRows(
new \ZtdQuery\Platform\MySql\Sql\Value\MySqlCastRenderer(),
new \ZtdQuery\Platform\MySql\Rewrite\GeneratedColumn\MySqlGeneratedColumnProjector(),
new \ZtdQuery\Platform\MySql\Sql\MySqlIdentifierQuoter(),
new \ZtdQuery\Platform\MySql\Sql\Value\MySqlValueRenderer());
$rows->generateCte('users', [['id' => 1]], ['id'], [], []) // => '`users` AS (SELECT CAST(1 AS SIGNED) AS `id`)'Methods§
public function __construct(
private CastRenderer $castRenderer,
private MySqlGeneratedColumnProjector $generatedColumnProjector,
private IdentifierQuoter $quoter,
private ValueRenderer $valueRenderer,
)Configure the dependencies used by this operation.
Parameters
$castRenderer | CastRenderer | |
$generatedColumnProjector | MySqlGeneratedColumnProjector | |
$quoter | IdentifierQuoter | |
$valueRenderer | ValueRenderer |
public function generateCte(
string $tableName,
array<int, array<string, mixed>> $rows,
array<int, string> $columns,
array<string, ColumnDeclaration> $columnTypes,
array<string, string> $generatedExpressions,
): stringGenerate a CTE fragment for a single table.
Parameters
$tableName | string | |
$rows | array<int, array<string, mixed>> | |
$columns | array<int, string> | |
$columnTypes | array<string, ColumnDeclaration> | |
$generatedExpressions | array<string, string> |
Returns
stringThrows
RuntimeExceptionTest cases 2
Called from 1
Calls 7
- method-call IdentifierQuoter::quote() line 53
- new
RuntimeExceptionline 57 - method-call CteRows::wrapCte() line 59
- method-call CteRows::emptySelect() line 59
- function-call
array_keysline 64 - method-call CteRows::formatValue() line 65
- function-call
implodeline 68
public function wrapCte(
string $quotedTable,
string $baseSql,
array<int, string> $columns,
array<string, string> $generatedExpressions,
): stringParameters
$quotedTable | string | |
$baseSql | string | |
$columns | array<int, string> | |
$generatedExpressions | array<string, string> |
Returns
stringTest cases 1
CteRowsTest::testWrapCtecalls
Called from 2
- method-call ZtdQuery\Platform\MySql\Rewrite\Transformer\Shadow\CteRows::generateCte() packages/ztd-query-mysql/src/Rewrite/Transformer/Shadow/CteRows.php:59
- method-call ZtdQuery\Platform\MySql\Rewrite\Transformer\Shadow\CteRows::generateCte() packages/ztd-query-mysql/src/Rewrite/Transformer/Shadow/CteRows.php:70
Calls 1
- method-call MySqlGeneratedColumnProjector::project() line 88
public function formatValue(mixed $val, ?ColumnDeclaration $type = null): stringFormat Value for the supplied MySQL input.
Parameters
$val | mixed | |
$type | ?ColumnDeclaration |
Returns
stringTest cases 1
Called from 1
Calls 7
- function-call
is_scalarline 100 - class-const ColumnTypeFamily::STRING() line 101
- function-call
str_starts_withline 102 - function-call
strtoupperline 102 - method-call ValueNormalizer::normalizeSetValue() line 104
- new ValueNormalizer line 104
- method-call ValueRenderer::renderValue() line 107
public function emptySelect(
array<int, string> $columns,
array<string, ColumnDeclaration> $columnTypes,
): stringParameters
$columns | array<int, string> | |
$columnTypes | array<string, ColumnDeclaration> |
Returns
stringTest cases 1
Called from 1
Calls 5
- new ColumnDeclaration line 117
- class-const ColumnTypeFamily::STRING() line 117
- method-call CastRenderer::renderNullCast() line 118
- method-call IdentifierQuoter::quote() line 118
- function-call
implodeline 120
Private surface 4§
Implementation details, listed for orientation only.
private CastRenderer $castRendererprivate MySqlGeneratedColumnProjector $generatedColumnProjectorprivate IdentifierQuoter $quoterprivate ValueRenderer $valueRendererTest cases 16§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
Other tests reaching this symbol 11
MySqlSessionFactoryTestcallsMySqlRewriterTestcallsStatementRewriterTestcallsDeleteTransformerTestcallsInsertTransformerTestcallsMySqlTransformerTestcallsReplaceTransformerTestcallsSelectTransformerTestcallsUpdateTransformerTestcallsRowMutationResolverTestcallsMySqlMutationResolverTestcalls