Symfony

Doctrine ORM Basics

Entities, annotations, EntityManager, repositories, DQL, QueryBuilder, relationships

25 preguntas de entrevista·
Junior
1

What is Doctrine ORM in the context of Symfony?

Respuesta

Doctrine ORM is an Object-Relational Mapper that allows manipulating database data through PHP objects. It abstracts SQL queries by providing an object layer, making code more maintainable and portable across different database management systems. It's the default recommended ORM with Symfony.

2

Which PHP 8 attribute should be used to declare a class as a Doctrine entity?

Respuesta

The #[ORM\Entity] attribute is used to indicate to Doctrine that a PHP class is an entity mapped to a database table. This attribute replaces comment-based annotations and is part of the Doctrine\ORM\Mapping namespace. It can be combined with repositoryClass to specify a custom repository.

3

How to define an auto-incremented column as a primary key in a Doctrine entity?

Respuesta

To define an auto-incremented primary key, two attributes must be combined: #[ORM\Id] to mark the property as identifier, and #[ORM\GeneratedValue] to indicate the value will be automatically generated by the database. The default strategy is AUTO, which selects the appropriate method based on the DBMS.

4

What is the difference between persist() and flush() in EntityManager?

5

Which attribute should be used to map a string property to a VARCHAR column in Doctrine?

+22 preguntas de entrevista

Domina Symfony para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis