@@ -152,12 +152,6 @@ class BasicEntityPersister implements EntityPersister
152152 */
153153 protected array $ quotedColumns = [];
154154
155- /**
156- * The INSERT SQL statement used for entities handled by this persister.
157- * This SQL is only generated once per request, if at all.
158- */
159- private string |null $ insertSql = null ;
160-
161155 /**
162156 * The quote strategy.
163157 */
@@ -272,8 +266,8 @@ public function executeInserts(): void
272266 $ this ->assignDefaultVersionAndUpsertableValues ($ entity , $ id );
273267 }
274268
275- // Unset this queued insert, so that the prepareUpdateData() method knows right away
276- // (for the next entity already) that the current entity has been written to the database
269+ // Unset this queued insert, so that the prepareUpdateData() method (called via prepareInsertData() method)
270+ // knows right away (for the next entity already) that the current entity has been written to the database
277271 // and no extra updates need to be scheduled to refer to it.
278272 //
279273 // In \Doctrine\ORM\UnitOfWork::executeInserts(), the UoW already removed entities
@@ -1416,22 +1410,17 @@ protected function getSelectManyToManyJoinSQL(AssociationMapping&ManyToManyAssoc
14161410
14171411 public function getInsertSQL (): string
14181412 {
1419- if ($ this ->insertSql !== null ) {
1420- return $ this ->insertSql ;
1421- }
1422-
14231413 $ columns = $ this ->getInsertColumnList ();
14241414 $ tableName = $ this ->quoteStrategy ->getTableName ($ this ->class , $ this ->platform );
14251415
1426- if (empty ($ columns )) {
1427- $ identityColumn = $ this ->quoteStrategy ->getColumnName ($ this ->class ->identifier [0 ], $ this ->class , $ this ->platform );
1428- $ this ->insertSql = $ this ->platform ->getEmptyIdentityInsertSQL ($ tableName , $ identityColumn );
1416+ if ($ columns === []) {
1417+ $ identityColumn = $ this ->quoteStrategy ->getColumnName ($ this ->class ->identifier [0 ], $ this ->class , $ this ->platform );
14291418
1430- return $ this ->insertSql ;
1419+ return $ this ->platform -> getEmptyIdentityInsertSQL ( $ tableName , $ identityColumn ) ;
14311420 }
14321421
1433- $ values = [];
1434- $ columns = array_unique ($ columns );
1422+ $ placeholders = [];
1423+ $ columns = array_unique ($ columns );
14351424
14361425 foreach ($ columns as $ column ) {
14371426 $ placeholder = '? ' ;
@@ -1445,15 +1434,13 @@ public function getInsertSQL(): string
14451434 $ placeholder = $ type ->convertToDatabaseValueSQL ('? ' , $ this ->platform );
14461435 }
14471436
1448- $ values [] = $ placeholder ;
1437+ $ placeholders [] = $ placeholder ;
14491438 }
14501439
1451- $ columns = implode (', ' , $ columns );
1452- $ values = implode (', ' , $ values );
1453-
1454- $ this ->insertSql = sprintf ('INSERT INTO %s (%s) VALUES (%s) ' , $ tableName , $ columns , $ values );
1440+ $ columns = implode (', ' , $ columns );
1441+ $ placeholders = implode (', ' , $ placeholders );
14551442
1456- return $ this -> insertSql ;
1443+ return sprintf ( ' INSERT INTO %s (%s) VALUES (%s) ' , $ tableName , $ columns , $ placeholders ) ;
14571444 }
14581445
14591446 /**
0 commit comments