Czyste zapytanie

  public function test2(string $keyName, string $keyValue, int $lastStepNumber) {
        $status = ClientStatuses::TYPE_COMPLETED;

        $key = '{"' . $keyName . '" : "' . $keyValue . '"}';

        $createdAtCondition = (new \DateTime('now -30 days'))->format('Y-m-d');
        $sqlQuery = 'SELECT * FROM `multi_step_form_client_data` WHERE createdAt > :createdAt and stepNr = :stepNr and status = :status and JSON_CONTAINS(serializedData, :jsonKey)  order BY createdAt desc limit 1';
        $connection = $this->getEntityManager()->getConnection()->prepare($sqlQuery);
        $connection->bindParam(':stepNr', $lastStepNumber);
        $connection->bindParam(':status', $status);
        $connection->bindParam(':createdAt', $createdAtCondition);
        $connection->bindParam(':jsonKey', $key);
        $connection->execute();

        return $connection->fetch();
    }
Komentarze wyłączone