MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/help.cafsindia.com/vendor/doctrine/orm/src/NativeQuery.php
<?php

declare(strict_types=1);

namespace Doctrine\ORM;

use function array_values;
use function is_int;
use function key;
use function ksort;

/**
 * Represents a native SQL query.
 *
 * @final
 */
class NativeQuery extends AbstractQuery
{
    /** @var string */
    private $sql;

    /**
     * Sets the SQL of the query.
     *
     * @param string $sql
     *
     * @return $this
     */
    public function setSQL($sql): self
    {
        $this->sql = $sql;

        return $this;
    }

    /**
     * Gets the SQL query.
     */
    public function getSQL(): string
    {
        return $this->sql;
    }

    /**
     * {@inheritDoc}
     */
    protected function _doExecute()
    {
        $parameters = [];
        $types      = [];

        foreach ($this->getParameters() as $parameter) {
            $name = $parameter->getName();

            if ($parameter->typeWasSpecified()) {
                $parameters[$name] = $parameter->getValue();
                $types[$name]      = $parameter->getType();

                continue;
            }

            $value = $this->processParameterValue($parameter->getValue());
            $type  = $parameter->getValue() === $value
                ? $parameter->getType()
                : Query\ParameterTypeInferer::inferType($value);

            $parameters[$name] = $value;
            $types[$name]      = $type;
        }

        if ($parameters && is_int(key($parameters))) {
            ksort($parameters);
            ksort($types);

            $parameters = array_values($parameters);
            $types      = array_values($types);
        }

        return $this->_em->getConnection()->executeQuery(
            $this->sql,
            $parameters,
            $types,
            $this->_queryCacheProfile
        );
    }
}