Official release of TDBM 4

Today, we are very proud to announce the release of TDBM 4, the ORM that comes with the Mouf framework.

Want a preview? Take a look at those slides:

or head directly to the documentation

Major changes

  • TDBM 4 is a complete rewrite from TDBM 3, with a lot of energy put in better organizing the code and better unit testing
  • The global philosophy of TDBM stays the same: your database model is meaningful and TDBM will do it's best to generate PHP objects from your database model. It is therefore taking a completely different direction than what Doctrine ORM does.
  • TDBM does what it can to avoid the classical traps of the Active record design pattern. TDBM is well suited for simple to moderatly complex applications.
    • Beans can now be instantiated directly (no need to use the TDBMService for this)
  • TDBM 4 is relying on Doctrine DBAL for database access
  • TDBM 4 is built on top of MagicQuery. It can automatically discard unused parameters in a SQL query. This is very useful to seamlessly write filters.
  • TDBM 4 will automatically generate query methods based on the indexes in your database
  • As always with TDBM, a lot of energy has been put in simplifying the query process. TDBM will automatically detect joins between tables
  • TDBM 4 can automatically detect pivot tables and will generate many-to-many getters and setters accordingly.
  • Generated beans now support the inheritance between tables (using primary keys as a foreign key technique)
  • Results are no more simple arrays. They implement the beberlei/porpaginas library: you can now get offset/limit and the total count from the result object.
  • Beans do not have a save method any more. You need to use the DAO save method instead.

Minor changes

  • Improved support for singularizing names (countries => CountryBean instead of countries => CountrieBean, thanks to ICanBoogie/Inflector)
  • Primary keys can now be updated
  • In cursor more, queries can now be looped over several time (this will trigger the query several times in database)
  • Base DAOs are now named TableNameBaseDao instead of TableNameDaoBase (more coherent with bean naming)
  • Generated names for methods in beans has changed:
    • There is no longer getter and setters for "ID" columns that are foreign keys to other columns.
    • Foreign key getters and setters are now base on the column name rather than the table name. If you have a table "user" with a column "birth_country_id" pointing to a table "country", previously, TDBM was generating "getCountry/setCountry" methods along a "getCountryByBirthCountryId/setCountryByBirthCountryId" method. Now, it will only generate a "getBirthCountry/setBirthCountry" pair of methods.
  • New findObjectOrFail method that performs a findObject and throws an exception if no result is found.

What's next?

In the next version (TDBM 4.1), we plan to:

  • Make TDBM easily usable out of Mouf
    • This means adding a CLI tool to generate bean and DAOs
    • Adding a service provider to easily create the TDBM service
  • Migrate the library to PHP 7 only: support from older PHP versions will be dropped
Tags :