// Append pessimistic write lock to FROM clause if db platform supports it
$sql =
$query->
getSQL();
if (($fromPart =
$query->
getQueryPart('from'
)) && ($table =
$fromPart[0
]['table'
] ?? null
) && ($alias =
$fromPart[0
]['alias'
] ?? null
) ) { $fromClause =
sprintf('%s %s',
$table,
$alias);
$sql =
str_replace( sprintf('FROM %s WHERE',
$fromClause),
sprintf('FROM %s WHERE',
$this->driverConnection->
getDatabasePlatform()->
appendLockHint($fromClause, LockMode::PESSIMISTIC_WRITE
)),
$sql );
} // Wrap the rownum query in a sub-query to allow writelocks without ORA-02014 error
if ($this->driverConnection->
getDatabasePlatform() instanceof OraclePlatform
) { $sql =
$this->
createQueryBuilder('w'
) ->
where('w.id IN ('.
str_replace('SELECT a.* FROM', 'SELECT a.id FROM',
$sql).')'
) ->
getSQL();
}