Models

Models are the PHP representation of your database's tables.

note

📣  All commands have to be run in the api service (make api).

Generate#

console
php bin/console tdbm:generate

This command will regenerate the TDBM models (and DAOs - more on that in the next chapter).

Models come in two kinds of classes. For instance:

  • BaseUser.
  • User that extends BaseUser.

TDBM generates the first class, and it contains the default getters and setters.

You cannot modify it, but instead, edit the second class as TDBM does not override it.

note

📣  There are other kinds of classes in the src/api/src/Domain/Model folder, but they are not related to TDBM.

Create an instance#

Let's say you have a model Foo with the following properties:

  • bar, non-nullable.
  • baz, nullable.
$foo = new Foo($bar);
$foo->setBaz($baz);
note

📣  A constructor of a model requires non-nullable values.