Gets a sequence.

@param string $name The sequence name.

@return \Fridge\DBAL\Schema\Sequence The sequence.

@throws \Fridge\DBAL\Exception\SchemaException If the sequence does not exist.
327040
public function getSequence($name)
    {
        if (!$this->hasSequence($name)) {
            throw SchemaException::schemaSequenceDoesNotExist($this->getName(), $name);
        }

        return $this->sequences[$name];
    }
846457
public function lastInsertId($name = null)
    {
        // checking for nulls, Postgres doesn't handle nulls at all here
        if(is_null($name)) {
            throw new \Exception('Postgres requires a sequence name to get the last insert ID');
        }

        // use the primary key to try to get the sequence name
        $primary_key = $this->getPrimaryKey($name);
        $id = $this->pdo->lastInsertId($name.'_'.$primary_key.'_seq');
        if($id === false || is_null($id)) {
            throw new \Exception("Can't get last insert ID for ".$name."; you must supply the correct sequence name.");
        }
        return $id;
    }
1319326
public function get(string $name) : Type
    {
        if (! isset($this->instances[$name])) {
            throw DBALException::unknownColumnType($name);
        }

        return $this->instances[$name];
    }
514225
public function get($name)
    {
        if (isset($this->instances[$name])) {
            return $this->instances[$name];
        }
        if (! isset($this->registry[$name])) {
            $exceptionClass = static::NOT_FOUND_EXCEPTION;
            throw new $exceptionClass(
                sprintf(static::NOT_FOUND_MESSAGE, $name)
            );
        }
        try {
            $this->instances[$name] = $this->build($this->registry[$name], $name);
        } catch (Exception $e) {
            throw new RuntimeException(
                sprintf(static::BUILD_FAILURE_MESSAGE, $name),
                null,
                $e
            );
        }

        return $this->instances[$name];
    }
435468
public function getRelation($name)
    {
        // We want to run a relationship query without any constrains so that we will
        // not have to remove these where clauses manually which gets really hacky
        // and error prone. We don't want constraints because we add eager ones.
        $relation = Relation::noConstraints(function () use ($name) {
            $instance = $this->getModel()->newInstance();
            if (method_exists($instance, $name)) {
                return $instance->$name();
            }

            if ($relation = $instance->getRelationshipFromConfig($name)) {
                return $relation;
            }

            throw new RuntimeException("Call to undefined relationship [{$name}] on resource [{$this->getModel()->getTable()}].");
        });

        $nested = $this->relationsNestedUnder($name);

        // If there are nested relationships set on the query, we will put those onto
        // the query instances so that they can be handled after this relationship
        // is loaded. In this way they will all trickle down as they are loaded.
        if (count($nested) > 0) {
            $relation->getQuery()->with($nested);
        }

        return $relation;
    }
1187407
public static function get($name = null)
    {
        $name = $name ?: self::_DEFAULT;
        if (!isset(self::$caches[$name])) {
            throw new CacheException("Cache '$name' not found");
        }
        return self::$caches[$name];
    }
175558
public function getNode($name)
    {
        if (!array_key_exists($name, $this->nodes)) {
            throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
        }

        return $this->nodes[$name];
    }
356836
public function getTable($name)
    {
        if (!$this->hasTable($name)) {
            throw SchemaException::schemaTableDoesNotExist($this->getName(), $name);
        }

        return $this->tables[$name];
    }
1035145
private function _postgresqlSequenceExists($name)
    {
        $escape = Driver::$escape_char;
        $sql    = "select count(*) as {$escape}CNT{$escape} from information_schema.sequences where sequence_name = '$name'";
        $stmt   = self::query($sql);
        $rst    = $stmt->fetch(\PDO::FETCH_ASSOC);
        $rtn    = intval($rst["CNT"]) > 0;
        self::closeCursor($stmt);
        return $rtn;
    }
544022
public function getColumn($name)
    {
        if (!$this->hasColumn($name)) {
            throw SchemaException::tableColumnDoesNotExist($this->getName(), $name);
        }

        return $this->columns[$name];
    }
1210756
public function getNamedNativeQuery($name)
    {
        if ( ! isset($this->_attributes['namedNativeQueries'][$name])) {
            throw ORMException::namedNativeQueryNotFound($name);
        }

        return $this->_attributes['namedNativeQueries'][$name];
    }
622341
public function getInstance($name)
    {
        if(!isset($this->data[$name]))
        {
            $this->data[$name] = new \Yurun\Swoole\SharedMemory\Struct\PriorityQueue;
        }
        return $this->data[$name];
    }
1006088
public function get(string $name)
    {
        if (!isset(self::$namedStates[$name])) {
            throw new DomainException("Unknown state: $name");
        }
        return self::$namedStates[$name];
    }
393397
private function _oracleSequenceExists($name)
    {
        $escape = Driver::$escape_char;
        $sql    = "select count(sequence_name) as $escape"."CNT"."$escape from user_sequences where sequence_name='$name' or sequence_name='".strtolower($name)."' or sequence_name='".strtoupper($name)."'";
        $stmt   = self::query($sql);
        $rst    = $stmt->fetch(\PDO::FETCH_ASSOC);
        $rtn    = intval($rst["CNT"]) > 0;
        self::closeCursor($stmt);
        return $rtn;
    }
164718
public function getColumn(string $name): AbstractColumn
    {
        if (!$this->schema->hasColumn($name)) {
            throw new DefinitionException("Undefined column {$name} in {$this->schema->getName()}");
        }

        return clone $this->schema->column($name);
    }
789160
private function init($name, $first = 0)
    {
        if (null !== $this->find($name)) {
            throw new InvalidArgumentException(sprintf('Sequence with name %s already exists', $name));
        }

        if (false === Numeric::isPositiveInteger($first, false)) {
            throw new InvalidArgumentException('Initial value of a sequence must be a positive integer');
        }

        $query = 'INSERT INTO sequence (name, value) VALUE(:name, :value)';
        $params = array(
            'name'   => $name,
            'value'  => $first,
        );

        $this->getEntityManager()
            ->getConnection()
            ->executeUpdate($query, $params)
        ;

        return $first;
    }
938675
protected function getGenericSequence($sequence)
    {
        $name = $sequence['name'];
        $initialValue = (int) $sequence['initial_value'];
        $incrementSize = (int) $sequence['increment_size'];

        return new Sequence($name, $initialValue, $incrementSize);
    }