-
Notifications
You must be signed in to change notification settings - Fork 2
TypeConverter
Classes that convert values between PHP and PostgreSQL formats implement this interface.
It defines three methods:
-
output(mixed $value): string|null
- returns a string representation of PHP variable suitable for PostgreSQL queries -
input(string|null $native): mixed
- converts a string received from PostgreSQL to PHP variable of the proper type -
dimensions(): int
- returns number of array dimensions for PHP variable
dimensions()
method is needed for proper output of arrays by \sad_spirit\pg_wrapper\converters\containers\ArrayConverter
.
PostgreSQL does not enforce a number of dimensions for an array type, so an array passed to ArrayConverter::output()
can
legitimately have any number of dimensions. If the array's base type can also be represented by PHP array (e.g. geometric types),
then number returned by dimensions()
will help to understand where base type array ends and "outer" array begins.
TypeConverter
implementations whose behaviour may change based on connection properties (e.g. connected server version) should implement this interface, defining one additional method
-
setConnectionResource(resource $resource)
- Sets the connection resource this converter works with
Date and time converters currently implement this interface to check server's DateStyle
setting.