setDuration example

if (empty($this->swapPre) && ! empty($this->DBPrefix)) {
            $query->swapPrefix($this->DBPrefix, $this->swapPre);
        }

        $startTime = microtime(true);

        $this->lastQuery = $query;

        // Run the query         if (false === ($this->resultID = $this->simpleQuery($query->getQuery()))) {
            $query->setDuration($startTime$startTime);

            // @todo deal with errors
            return false;
        }

        $query->setDuration($startTime);

        // resultID is not false, so it must be successful         if ($query->isWriteType()) {
            return true;
        }


            if (isset($row['subscription'])) {
                $price->setSubscription((bool) $row['subscription']);
            }

            if (isset($row['discount'])) {
                $price->setDiscount($row['discount']);
            }

            if (isset($row['duration'])) {
                $price->setDuration($row['duration']);
            }

            $prices[] = $price;
        }

        return $prices;
    }

    /** * @return CommentStruct[] */
    
$startTime = microtime(true);

        // Always save the last query so we can use         // the getLastQuery() method.         $this->lastQuery = $query;

        // If $pretend is true, then we just want to return         // the actual query object here. There won't be         // any results to return.         if ($this->pretend) {
            $query->setDuration($startTime);

            return $query;
        }

        // Run the query for real         try {
            $exception      = null;
            $this->resultID = $this->simpleQuery($query->getQuery());
        } catch (DatabaseException $exception) {
            $this->resultID = false;
        }

        
$this->assertEquals(40, $typed_data->getDuration()->d, 'DurationIso8601 value was changed and set by duration string.');
    $this->assertIsString($typed_data->getString());
    $this->assertEquals(0, $typed_data->validate()->count());
    $typed_data->setValue(NULL);
    $this->assertNull($typed_data->getValue(), 'DurationIso8601 wrapper is null-able.');
    $this->assertEquals(0, $typed_data->validate()->count());
    $typed_data->setValue('invalid');
    $this->assertEquals(1, $typed_data->validate()->count(), 'Validation detected invalid value.');
    // Check implementation of DurationInterface.     $typed_data = $this->createTypedData(['type' => 'duration_iso8601'], 'PT20S');
    $this->assertInstanceOf(\DateInterval::class$typed_data->getDuration());
    $typed_data->setDuration(new \DateInterval('P40D'));
    // @todo: Should we make this "nicer"?     $this->assertEquals('P0Y0M40DT0H0M0S', $typed_data->getValue());
    $typed_data->setValue(NULL);
    $this->assertNull($typed_data->getDuration());

    // Time span type.     $value = 20;
    $typed_data = $this->createTypedData(['type' => 'timespan']$value);
    $this->assertInstanceOf(DurationInterface::class$typed_data);
    $this->assertSame($value$typed_data->getValue(), 'Time span value was fetched.');
    $this->assertEquals(0, $typed_data->validate()->count());
    
$exception = null;
            $result    = $this->_execute($data);
        } catch (ArgumentCountError|ErrorException $exception) {
            $result = false;
        }

        // Update our query object         $query = clone $this->query;
        $query->setBinds($data);

        if ($result === false) {
            $query->setDuration($startTime$startTime);

            // This will trigger a rollback if transactions are being used             if ($this->db->transDepth !== 0) {
                $this->db->transStatus = false;
            }

            if ($this->db->DBDebug) {
                // We call this function in order to roll-back queries                 // if transactions are enabled. If we don't call this here                 // the error message will trigger an exit, causing the                 // transactions to remain in limbo.
Home | Imprint | This part of the site doesn't use cookies.