connection->quoteIdentifier('key'); $qb = $this->connection->createQueryBuilder(); $qb->select($keyColumnName) ->from('api_keys'); $result = $qb->executeQuery(); $updateQb = $this->connection->createQueryBuilder(); $updateQb ->update('api_keys') ->set($keyColumnName, ':encryptedKey') ->where($updateQb->expr()->eq($keyColumnName, ':plainTextKey')); while ($key = $result->fetchOne()) { $updateQb->setParameters([ 'encryptedKey' => hash('sha256', $key), 'plainTextKey' => $key, ])->executeStatement(); } } public function isTransactional(): bool { return ! ($this->connection->getDatabasePlatform() instanceof MySQLPlatform); } }