Please test Nette Database 4.0 RC
- David Grudl
- Nette Core | 8228
Please test the new major version of Nette Database 4.0 RC
composer require nette/database:^4.0.0-dev
The new version introduces a significant architectural change. It is
no longer tightly coupled with PDO. This allows the addition of drivers
for other PHP database extensions, such as mysqli
, which will
enable running queries in parallel—a potentially very interesting feature.
Another update is the merging of the Nette\Database\Connection
and Explorer
classes into one. This was how it used to be in NDB,
and I think it's a good idea to return to this concept. The names of these
classes are now aliases.
A new feature allows you to configure how values fetched from the database are converted, using the following options:
database:
dsn: ...
options:
convertBoolean: true # Converts MySQL tinyint(1) / BIT in SQLServer to boolean
convertDateTime: true # Whether to convert dates to DateTime objects
convertDecimal: true # Whether to convert to int/float or leave as string
All these options are enabled by default, as well as the newDateTime
option.
Changes:
- The
getInsertId()
method now returns integers instead of strings. - The
DriverException::getCode()
method returns a numeric driver-specific code instead of an SQLstate string. - I've removed the
IRow
andIRowContainer
interfaces from the code as I believe they weren't particularly useful. - Methods strictly related to PDO have been deprecated:
Connection::getPdo()
,getDsn()
.
I've got a few exciting new features that require the new architecture of Nette Database 4.0.
And although the new version has been completely revamped under the hood, I've tried to ensure it doesn't cause any incompatibilities. I didn't need to make any changes to my projects. Please check if you encounter any incompatibilities so we can address them.
Is there anyone who has created their own database driver for NDB?
- SamuelThorn
- Member | 29
I've tried on one of my simple projects. Everything worked.
Only problem was TypeError caused by conflict of
Nette\Utils\DateTime
and Nette\Database\DateTime
,
which was my mistake.