@@ -153,12 +153,6 @@ class BasicEntityPersister implements EntityPersister
153153 */
154154 protected array $ quotedColumns = [];
155155
156- /**
157- * The INSERT SQL statement used for entities handled by this persister.
158- * This SQL is only generated once per request, if at all.
159- */
160- private string |null $ insertSql = null ;
161-
162156 /**
163157 * The quote strategy.
164158 */
@@ -273,8 +267,8 @@ public function executeInserts(): void
273267 $ this ->assignDefaultVersionAndUpsertableValues ($ entity , $ id );
274268 }
275269
276- // Unset this queued insert, so that the prepareUpdateData() method knows right away
277- // (for the next entity already) that the current entity has been written to the database
270+ // Unset this queued insert, so that the prepareUpdateData() method (called via prepareInsertData() method)
271+ // knows right away (for the next entity already) that the current entity has been written to the database
278272 // and no extra updates need to be scheduled to refer to it.
279273 //
280274 // In \Doctrine\ORM\UnitOfWork::executeInserts(), the UoW already removed entities
@@ -1418,22 +1412,17 @@ protected function getSelectManyToManyJoinSQL(AssociationMapping&ManyToManyAssoc
14181412
14191413 public function getInsertSQL (): string
14201414 {
1421- if ($ this ->insertSql !== null ) {
1422- return $ this ->insertSql ;
1423- }
1424-
14251415 $ columns = $ this ->getInsertColumnList ();
14261416 $ tableName = $ this ->quoteStrategy ->getTableName ($ this ->class , $ this ->platform );
14271417
1428- if (empty ($ columns )) {
1429- $ identityColumn = $ this ->quoteStrategy ->getColumnName ($ this ->class ->identifier [0 ], $ this ->class , $ this ->platform );
1430- $ this ->insertSql = $ this ->platform ->getEmptyIdentityInsertSQL ($ tableName , $ identityColumn );
1418+ if ($ columns === []) {
1419+ $ identityColumn = $ this ->quoteStrategy ->getColumnName ($ this ->class ->identifier [0 ], $ this ->class , $ this ->platform );
14311420
1432- return $ this ->insertSql ;
1421+ return $ this ->platform -> getEmptyIdentityInsertSQL ( $ tableName , $ identityColumn ) ;
14331422 }
14341423
1435- $ values = [];
1436- $ columns = array_unique ($ columns );
1424+ $ placeholders = [];
1425+ $ columns = array_unique ($ columns );
14371426
14381427 foreach ($ columns as $ column ) {
14391428 $ placeholder = '? ' ;
@@ -1447,15 +1436,13 @@ public function getInsertSQL(): string
14471436 $ placeholder = $ type ->convertToDatabaseValueSQL ('? ' , $ this ->platform );
14481437 }
14491438
1450- $ values [] = $ placeholder ;
1439+ $ placeholders [] = $ placeholder ;
14511440 }
14521441
1453- $ columns = implode (', ' , $ columns );
1454- $ values = implode (', ' , $ values );
1455-
1456- $ this ->insertSql = sprintf ('INSERT INTO %s (%s) VALUES (%s) ' , $ tableName , $ columns , $ values );
1442+ $ columns = implode (', ' , $ columns );
1443+ $ placeholders = implode (', ' , $ placeholders );
14571444
1458- return $ this -> insertSql ;
1445+ return sprintf ( ' INSERT INTO %s (%s) VALUES (%s) ' , $ tableName , $ columns , $ placeholders ) ;
14591446 }
14601447
14611448 /**
0 commit comments