Type Conversion
Nette Database automatically converts values retrieved from the database into the appropriate PHP types.
Date and Time
Date and time values are converted into Nette\Utils\DateTime
objects. If you prefer date and time values to be
converted into immutable Nette\Database\DateTime
objects, enable the newDateTime
option in the configuration.
For MySQL, the TIME
data type is converted into DateInterval
objects.
Boolean Values
Boolean values are automatically normalized to true
or false
. In MySQL, the TINYINT(1)
type is converted when the convertBoolean
option is enabled in the configuration.
Numeric Values
Numeric values are cast to int
or float
, depending on the column type in the database:
Custom Normalization
You can define a custom function to transform database rows using the setRowNormalizer(?callable $normalizer)
method. This is useful, for example, for automatic data type conversion.