TDBM generates PHP files from your database model.
The way you generate DAOs and beans depends on the framework you use.
TDBMService, without generating DAOs or beans. This is mostly for testing purpose and is not recommended. Should you need it, you can check the
tests/TDBMServiceTest.phpfile for usage samples.
For each table in your database, TDBM will generate a DAO and a bean. The DAO is the object you will use to query the database. Each row of the database will be mapped to a bean object.
Both DAOs and beans are divided in 2 parts. Let's assume you have a "users" table. TDBM will generate those classes for you:
AbstractUserDao: the base class that contains methods to access the "users" table. It is generated by TDBM and you should never modify this class.
UserDao: this class extends AbstractUserDao. If you have some custom requests, you should perform them in this class. You can edit it as TDBM will never overwrite it.
AbstractUser: the bean mapping the columns of the "users" table. This class contains getters and setters for each and every column of the "users" table. It is generated by TDBM and you should never modify this class.
User: this class extends AbstractUser. If you have some custom getters and setters, you should implement them in this class. You can edit it as TDBM will never overwrite it.
Let's now have a closer look at the methods that are available in the "UserDao" class:
public function save(User $obj): saves a
Userobject in database
public function findAll(): returns all users records as an array of
public function getById($id, bool $lazyLoading = false): Get a
Userspecified by its ID (its primary key)
public function delete($obj, $cascade=false): Deletes the User passed in parameter. If
$cascadeis set to true, it will delete all objects linked to
The last 2 functions are protected. It means they are designed to be used in the UserDao class.
protected function find($filter=null, $parameters = , $orderbyBag=null): returns a list of users based on a filter bag (see the
TDBM_Servicedocumentation to learn more about filter bags). You can also provide an order, and an offset / limit range.
protected function findOne($filter=null, $parameters = ): this has exactly the same purpose as find except it returns only 1 bean object instead of a list of bean objects.
Found a typo? Something is wrong in this documentation? Just fork and edit it!