classBufferedRow
final class BufferedRow
Shapes a row ZTD buffered into what a fetch mode asks for.
A simulated statement never reaches the driver, so nothing shapes its rows the way PDO's own fetch modes would. The rows come back keyed by column; this turns one of them into the array, list or object the caller asked to fetch.
Methods§
public function inMode<TValue>(
array<string, TValue> $row,
int $mode,
): array<int|string, TValue>|TValue|stdClass|falseAnswers the row in the shape a fetch mode asks for.
A mode this does not know is read as PDO reads an unknown one: both ways at once, which is what PDO::FETCH_BOTH means.
Parameters
$row | array<string, TValue> | Row as ZTD buffered it, keyed by column |
$mode | int | One of PDO::FETCH_* |
Returns
array<int|string, TValue>|TValue|stdClass|false The row or column selected by the fetch modeTest cases 7
BufferedRowTest::testInModeAnswersAModeItDoesNotKnowBothWaysAtOncecallsBufferedRowTest::testInModeAnswersANamedFetchTheSameWayAsAKeyedOnecallsBufferedRowTest::testInModeAnswersAnObjectWhereOneIsAskedcallsBufferedRowTest::testInModeAnswersFalseWhereOneColumnIsAskedOfAnEmptyRowcallsBufferedRowTest::testInModeAnswersTheFirstValueWhereOneColumnIsAskedcallsBufferedRowTest::testInModeAnswersTheRowKeyedByColumnWhereThatIsAskedcallsBufferedRowTest::testInModeAnswersTheValuesAloneWhereOnlyPositionsAreAskedcalls
Called from 2
public function keyedBothWays<TValue>(array<string, TValue> $row): array<int|string, TValue>Answers the row keyed by column name and by position at once.
Parameters
$row | array<string, TValue> | Row as ZTD buffered it, keyed by column |
Returns
array<int|string, TValue> The same values, reachable under either keyTest cases 2
public function resolveMode(int $mode, int $connectionMode, ?int $statementMode): intResolve FETCH_DEFAULT using statement options before connection options.
Parameters
$mode | int | |
$connectionMode | int | |
$statementMode | ?int |
Returns
intCalled from 2
Calls 1
- class-const
PDO::FETCH_DEFAULT()line 72
public function fetch<TValue>(
array<string, TValue>|false $row,
int $mode,
): array<int|string, TValue>|TValue|stdClass|falseShape a buffered row while preserving the exhausted-cursor marker.
Parameters
$row | array<string, TValue>|false | |
$mode | int |
Returns
array<int|string, TValue>|TValue|stdClass|falseTest cases 1
Called from 1
Calls 1
- method-call BufferedRow::inMode() line 84
public function all<TValue, TArgument>(
array<int, array<string, TValue>> $rows,
int $mode,
array<TArgument> $arguments,
): list<array<int|string, TValue>|TValue|stdClass|false>Shape all remaining rows, including column selection arguments.
Parameters
$rows | array<int, array<string, TValue>> | |
$mode | int | |
$arguments | array<TArgument> |
Returns
list<array<int|string, TValue>|TValue|stdClass|false>Test cases 1
Called from 1
Calls 4
- function-call
is_intline 99 - class-const
PDO::FETCH_COLUMN()line 101 - method-call BufferedRow::column() line 102
- method-call BufferedRow::inMode() line 103
public function column<TValue>(array<string, TValue>|false $row, int $column): TValue|falseRead one positional column while preserving the exhausted-cursor marker.
Parameters
$row | array<string, TValue>|false | |
$column | int |
Returns
TValue|falseTest cases 1
Called from 2
Calls 1
- function-call
array_valuesline 117
public function object<TValue, TObject of object, TArgument>(
array<string, TValue>|false $row,
class-string<TObject>|null $class,
array<TArgument> $constructorArgs,
): ($class is null ? stdClass : TObject)|falseHydrate a buffered row after invoking its constructor.
Parameters
$row | array<string, TValue>|false | |
$class | class-string<TObject>|null | |
$constructorArgs | array<TArgument> |
Returns
($class is null ? stdClass : TObject)|falseThrows
ReflectionException When a declared property cannot be written.Test cases 2
Called from 1
Test cases 24§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 15
BufferedRowTest::testAllShapesRowsAndSelectsTheRequestedColumncallsBufferedRowTest::testColumnPreservesNullAndMissingColumnBehaviorcallsBufferedRowTest::testFetchPreservesValuescallsBufferedRowTest::testInModeAnswersAModeItDoesNotKnowBothWaysAtOncecallsBufferedRowTest::testInModeAnswersANamedFetchTheSameWayAsAKeyedOnecallsBufferedRowTest::testInModeAnswersAnObjectWhereOneIsAskedcallsBufferedRowTest::testInModeAnswersFalseWhereOneColumnIsAskedOfAnEmptyRowcallsBufferedRowTest::testInModeAnswersTheFirstValueWhereOneColumnIsAskedcallsBufferedRowTest::testInModeAnswersTheRowKeyedByColumnWhereThatIsAskedcallsBufferedRowTest::testInModeAnswersTheValuesAloneWhereOnlyPositionsAreAskedcallsBufferedRowTest::testKeyedBothWaysAnswersNothingForARowWithNoColumnscallsBufferedRowTest::testKeyedBothWaysReachesEveryValueUnderEitherKeycallsBufferedRowTest::testObjectHydratesDeclaredPropertiesAfterConstructioncallsBufferedRowTest::testObjectPreservesAnonymousRowsAndEndOfCursorcallsBufferedRowTest::testResolveModeUsesExplicitThenStatementThenConnectionModecalls
Other tests reaching this symbol 9
PdoConnectionTestcallsPdoStatementTestcallsDriverSessionFactoryTestcallsParameterBinderTestcallsPreparedQueryTestcallsStatementExecutionTestcallsZtdPdoExceptionTestcallsZtdPdoStatementTestcallsZtdPdoTestcalls
Relations§
Instantiated in 1
Method calls 6
- method-call ZtdQuery\Adapter\Pdo\ZtdPdoStatement::fetch() packages/ztd-query-pdo-adapter/src/ZtdPdoStatement.php:189
- method-call ZtdQuery\Adapter\Pdo\ZtdPdoStatement::fetch() packages/ztd-query-pdo-adapter/src/ZtdPdoStatement.php:190
- method-call ZtdQuery\Adapter\Pdo\ZtdPdoStatement::fetchAll() packages/ztd-query-pdo-adapter/src/ZtdPdoStatement.php:212
- method-call ZtdQuery\Adapter\Pdo\ZtdPdoStatement::fetchAll() packages/ztd-query-pdo-adapter/src/ZtdPdoStatement.php:213
- method-call ZtdQuery\Adapter\Pdo\ZtdPdoStatement::fetchColumn() packages/ztd-query-pdo-adapter/src/ZtdPdoStatement.php:234
- method-call ZtdQuery\Adapter\Pdo\ZtdPdoStatement::fetchObject() packages/ztd-query-pdo-adapter/src/ZtdPdoStatement.php:266