Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is there an onupdate in php-orm doctrine manytoone?


Asked by Eleanor Casey on Dec 02, 2021 PHP



As you already said there is no onUpdate. Another downside is that ON DELETE CASCADE only works on InnoDB. It doesn't work on MyISAM. It's all described in the documentation: https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#transitive-persistence-cascade-operations
Indeed,
The updating of databases uses a diff algorithm for a given database schema. This is a cornerstone of the Doctrine\DBAL package, which can even be used without the Doctrine ORM package. We start with the simplest entity, the Product. Create a src/Product.php file to contain the Product entity definition:
Additionally, It is strongly recommended to switch to one of the other mappings. Doctrine's public interface is through the EntityManager. This class provides access points to the complete lifecycle management for your entities, and transforms entities from and back to persistence. You have to configure and create it to use your entities with Doctrine ORM.
Moreover,
Doctrine has a command-line interface that allows you to access the SchemaTool, a component that can generate a relational database schema based entirely on the defined entity classes and their metadata. For this tool to work, a cli-config.php file must exist in the project root directory:
In fact,
In the example above, we avoid all possible logic in the entity and only care about putting and retrieving data into it without validation (except the one provided by type-hints) nor consideration about the object's state. As Doctrine ORM is a persistence tool for your domain, the state of an object is really important.