{@inheritdoc}

@param  null $sequence

@return integer|string|array
971858
public function execute($sequence = null)
    {
        $result = Db::query($this->getSql(), $this->params, $this->types);
        if ($result) {
            return Db::handler()->lastInsertId($sequence);
        }
        return $result;
    }
1020853
protected function getGenericSequences(array $sequences)
    {
        $genericSequences = array();

        foreach ($sequences as $sequence) {
            $genericSequences[] = $this->getGenericSequence($sequence);
        }

        return $genericSequences;
    }
947467
public function toASN1(): Sequence
    {
        $elements = array($this->_issuer->toASN1(), new Integer($this->_serial));
        if (isset($this->_issuerUID)) {
            $elements[] = $this->_issuerUID->toASN1();
        }
        return new Sequence(...$elements);
    }
180824
public function insertGetId(array $values, $sequence = null)
    {
        $sql = $this->grammar->compileInsertGetId($this, $values, $sequence);
        $values = $this->cleanBindings($values);
        $this->connection->query($sql, $values);

        return $this->connection->insert_id();
    }
633393
protected static function getSequenceCurval( array $sequences, Pg $db )
    {

        // anything to do
        if( !$sequences ) {
            return array();
        }

        // sequence components
        foreach( $sequences as $key => &$sequence ) {

            $sequence = sprintf(
                "currval('%s'::regclass) as %s",
                $sequence,
                Query::quoteIdentifier( $key )
            );

        }
        $sequences = implode(', ', $sequences);

        return $db->query( new Query( "SELECT {$sequences};" ) )->fetchSingle( Result::FLATTEN_PREVENT );

    }
646960
public function insertGetId(array $values, $sequence = null) {
        $sql = $this->grammar->compileInsertGetId($this, $values, $sequence);
        $values = $this->cleanBindings($values);
        $res = $this->connection->insert($sql);
        $res = $res->getData();
        if (isset($res[0])) {
            return $res[0]['@rid'];
        }
        return false;
    }
180739
public static function fromASN1(Sequence $seq): RSAPrivateKey
    {
        $version = $seq->at(0)
            ->asInteger()
            ->intNumber();
        if ($version != 0) {
            throw new \UnexpectedValueException("Version must be 0.");
        }
        // helper function get integer from given index
        $get_int = function ($idx) use ($seq) {
            return $seq->at($idx)
                ->asInteger()
                ->number();
        };
        $n = $get_int(1);
        $e = $get_int(2);
        $d = $get_int(3);
        $p = $get_int(4);
        $q = $get_int(5);
        $dp = $get_int(6);
        $dq = $get_int(7);
        $qi = $get_int(8);
        return new self($n, $e, $d, $p, $q, $dp, $dq, $qi);
    }
1261195
protected function insertData($sequence)
    {
        // 自动写入
        $this->autoCompleteData($this->insert);

        // 时间戳自动写入
        $this->checkTimeStampWrite();

        if (false === $this->trigger('before_insert')) {
            return false;
        }

        // 检查允许字段
        $allowFields = $this->checkAllowFields(array_merge($this->auto, $this->insert));

        $db = $this->db(false);
        $db->startTrans();

        try {
            $result = $db->strict(false)
                ->field($allowFields)
                ->insert($this->data, $this->replace, false, $sequence);

            // 获取自动增长主键
            if ($result && $insertId = $db->getLastInsID($sequence)) {
                $pk = $this->getPk();

                foreach ((array) $pk as $key) {
                    if (!isset($this->data[$key]) || '' == $this->data[$key]) {
                        $this->data[$key] = $insertId;
                    }
                }
            }

            // 关联写入
            if (isset($this->relationWrite)) {
                $this->autoRelationInsert();
            }

            $db->commit();

            // 标记为更新
            $this->exists = true;

            // 新增回调
            $this->trigger('after_insert');

            return $result;
        } catch (\Exception $e) {
            $db->rollback();
            throw $e;
        }
    }
1110368
protected function get_sequence( $pattern ) {
		$characters = Strings::mb_str_split( str_replace( '.', '_', $pattern ) );
		$result     = [];

		foreach ( $characters as $index => $chr ) {
			if ( ctype_digit( $chr ) ) {
				$result[] = $chr;
			} else {
				// Append '0' if this is the first character or the previous character was not a number.
				if ( ! isset( $characters[ $index - 1 ] ) || ! ctype_digit( $characters[ $index - 1 ] ) ) {
					$result[] = '0';
				}

				// Append '0' if this is the last character.
				if ( ! isset( $characters[ $index + 1 ] ) ) {
					$result[] = '0';
				}
			}
		}

		// Do some error checking.
		$count     = count( $result );
		$count_seg = mb_strlen( $this->get_segment( $pattern ) );
		$sequence  = implode( '', $result );

		if ( $count !== $count_seg + 1 ) {
			throw new \RangeException( "Invalid segment length $count for pattern $pattern (result sequence $sequence)." );
		}

		return $sequence;
	}
782881
public function createSequence($sequence)
    {
        $changeSetElt = $this->createChangeSet('create-sequence-' . $sequence->getName());

        $sequenceName = QualifiedName::fromAsset($sequence);
        $createSequenceElt = $this->document->createElement('createSequence');

        if ($sequenceName->getNamespaceName()) {
            $createSequenceElt->setAttribute('schemaName', $sequenceName->getNamespaceName());
        }
        $createSequenceElt->setAttribute('sequenceName', $sequenceName->getName());
        $createSequenceElt->setAttribute('startValue', $sequence->getInitialValue());

        $changeSetElt->appendChild($createSequenceElt);
        $this->root->appendChild($changeSetElt);
    }
1252517
protected function getGenericSequence($sequence)
    {
        $sql = 'SELECT'.
               '  min_value AS initial_value,'.
               '  increment_by AS increment_size'.
               ' FROM '.$sequence['name'];

        $datas = $this->getConnection()->fetchAssoc($sql);

        return parent::getGenericSequence(
            array(
                'name'           => $sequence['name'],
                'initial_value'  => $datas['initial_value'],
                'increment_size' => $datas['increment_size'],
            )
        );
    }
878945
public function toASN1(): Sequence
    {
        $elements = array_values(
            array_map(
                function ($ext) {
                    return $ext->toASN1();
                }, $this->_extensions));
        return new Sequence(...$elements);
    }
721282
public static function flatten (array $sequence)
    {
        $flat = array();
        array_walk_recursive($sequence, function ($element) use (&$flat) { $flat []= $element; });
        return $flat;
    }
447267
public function asSequence(): Constructed\Sequence
    {
        if (!$this->_element instanceof Constructed\Sequence) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_SEQUENCE));
        }
        return $this->_element;
    }
14895
public function _nextSequence($sequence)
    {
        $sequence = strtoupper($sequence);
        $id = $this->_lockSequence($sequence);
        $increment = $this->_connection->execute(
            "UPDATE sequences SET id=id+1 WHERE name=?", $sequence);

        return $id;
    }
352302
public function toASN1(): Sequence
    {
        $elements = array_map(
            function (RDN $rdn) {
                return $rdn->toASN1();
            }, $this->_rdns);
        return new Sequence(...$elements);
    }
737239
private static function parseSequence($sequence, $flags, &$i = 0, $references = array())
    {
        $output = array();
        $len = \strlen($sequence);
        ++$i;

        // [foo, bar, ...]
        while ($i < $len) {
            if (']' === $sequence[$i]) {
                return $output;
            }
            if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
                ++$i;

                continue;
            }

            $tag = self::parseTag($sequence, $i, $flags);
            switch ($sequence[$i]) {
                case '[':
                    // nested sequence
                    $value = self::parseSequence($sequence, $flags, $i, $references);
                    break;
                case '{':
                    // nested mapping
                    $value = self::parseMapping($sequence, $flags, $i, $references);
                    break;
                default:
                    $isQuoted = \in_array($sequence[$i], array('"', "'"));
                    $value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references);

                    // the value can be an array if a reference has been resolved to an array var
                    if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
                        // embedded mapping?
                        try {
                            $pos = 0;
                            $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references);
                        } catch (\InvalidArgumentException $e) {
                            // no, it's not
                        }
                    }

                    --$i;
            }

            if (null !== $tag) {
                $value = new TaggedValue($tag, $value);
            }

            $output[] = $value;

            ++$i;
        }

        throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
    }