appendLockHint example



            // 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();
            }

            
if ($filterSql !== '') {
            $conditionSql = $conditionSql
                ? $conditionSql . ' AND ' . $filterSql
                : $filterSql;
        }

        $select = 'SELECT ' . $columnList;
        $from   = ' FROM ' . $tableName . ' ' . $tableAlias;
        $join   = $this->currentPersisterContext->selectJoinSql . $joinSql;
        $where  = ($conditionSql ? ' WHERE ' . $conditionSql : '');
        $lock   = $this->platform->appendLockHint($from$lockMode ?? LockMode::NONE);
        $query  = $select
            . $lock
            . $join
            . $where
            . $orderBySql;

        return $this->platform->modifyLimitQuery($query$limit$offset ?? 0) . $lockSql;
    }

    /** * {@inheritDoc} */
Home | Imprint | This part of the site doesn't use cookies.