Symfony update czysty sql

 /**
     * restore suspended items
     * (with status in_progress and olther then 7 days)
     *
     * @return bool
     */
    public function restoreSuspendedItems(): bool
    {
        $maxDatetimeAdd = (new \DateTime('now - 7 days'))->format('Y-m-d H:i:s');
        try {
            $sqlQuery = 'UPDATE rb_sms_storage SET status= "' . SmsResultStatuses::WAITING . '" WHERE status = "' . SmsResultStatuses::IN_PROGRESS . '" AND datetime_add <= "' . $maxDatetimeAdd . '"';
            $connection = $this->getEntityManager()->getConnection()->prepare($sqlQuery);

            $connection->execute();
            return true;
        } catch (\Exception $ex) {
            return false;
        }
    }
Komentarze wyłączone