Answer the question
In order to leave comments, you need to log in
How to create multiple records in a table with doctrine in one query?
In sql, to add multiple records in one query, you can do this:
insert into tablename (id,blabla) values(1,'werwer'),(2,'wqewqe'),(3,'qwewe');
public function addImages($idService, $newFilePath, $userId){
// Подключение менеджера сущьностей Doctrine
$em = $this->managerInterface;
// Запись изображений в таблицу в таблицу
foreach ($newFilePath as $key=>$value){
// Создание экземпляра сущьности
$images = new ServiceImages();
$images->setIdService($idService);
$images->setPathImages($value['PATH']);
$images->setNameImages($value['NAME']);
$images->setIdUser($userId);
$em->persist($images);
// Запись
}
$em->flush();
}
Answer the question
In order to leave comments, you need to log in
No way.
Of course, you can write a "raw" sql query bypassing doctrine, or even do LOAD DATA INFILE if there is really a lot of data. But these are already features that are implemented differently in different DBMS and the doctrine does not deal with this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question