Find and use an unused non-sequential ID for a record, as part of a
model's creation. ID will be a 32-bit unsigned integer of 10 characters
in length.

@return void
542435
protected static function boot()
    {
        parent::boot();

        self::creating(function ($model) {
            do {
                $id = mt_rand(pow(10, 9), pow(2, 32) - 1);
            } while (self::find($id));

            $model->{$model->getKeyName()} = $id;
        });
    }
694412
public function insert_id()
	{
		$query = version_compare($this->version(), '8', '>=')
			? 'SELECT SCOPE_IDENTITY() AS last_id'
			: 'SELECT @@IDENTITY AS last_id';

		$query = $this->query($query);
		$query = $query->row();
		return $query->last_id;
	}
243790
public function getRecordID()
    {
        $id = $this->getDataValue('id');
        return is_null($id) ? null : is_numeric($id) ? intval($id) : $id;
    }
860217
def id(self, id):
        

        if id is None:
            raise ValueError("Invalid value for `id`, must not be `None`")
        if len(id) > 255:
            raise ValueError("Invalid value for `id`, length must be less than `255`")

        self._id = id
1039358
protected function generateId()
    {
        static $choices = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $id = '';
        while (strlen($id) < 9) {
            $id .= $choices[ mt_rand(0, strlen($choices) - 1) ];
        }
        return $id;
    }
1101397
public function find($id)
    {
        $rel = $this->currentOrClone();
        $modelClass = $this->modelClass;
        $tableName  = $modelClass::tableName();
        $first = $rel->where([$tableName . '.' . $modelClass::primaryKey() => $id])->first();
        if (!$first) {
            throw new RecordNotFoundException(sprintf(
                "Couldn't find %s with %s=%s",
                $this->modelClass,
                $modelClass::primaryKey(),
                $id
            ));
        }
        return $first;
    }
969504
public function getNextId()
    {
        $sequence = $this->dbHandler->getSequenceName('ezurlalias_ml_incr', 'id');
        /** @var $query \eZ\Publish\Core\Persistence\Database\InsertQuery */
        $query = $this->dbHandler->createInsertQuery();
        $query->insertInto(
            $this->dbHandler->quoteTable('ezurlalias_ml_incr')
        );
        // ezcDatabase does not abstract the "auto increment id"
        // INSERT INTO ezurlalias_ml_incr VALUES(DEFAULT) is not an option due
        // to this mysql bug: http://bugs.mysql.com/bug.php?id=42270
        // as a result we are forced to check which database is currently used
        // to generate the correct SQL query
        // see https://jira.ez.no/browse/EZP-20652
        if ($this->dbHandler->useSequences()) {
            $query->set(
                $this->dbHandler->quoteColumn('id'),
                "nextval('{$sequence}')"
            );
        } else {
            $query->set(
                $this->dbHandler->quoteColumn('id'),
                $query->bindValue(null, null, \PDO::PARAM_NULL)
            );
        }
        $query->prepare()->execute();

        return $this->dbHandler->lastInsertId($sequence);
    }
38092
public function findRecord($id)
    {
        if (is_object($id)) {
            return $id;
        }

        if (is_numeric($id) or $this->shouldBeNumber($id)) {
            return $this->findById($id);
        }

        if (is_string($id)) {
            return $this->findByIdentifier($id);
        }
    }
1137865
public function getId()
    {
      $decoded = $this->getDecoded();
      return !is_null($decoded)
                ? $decoded->data->{$this->id_field}
                : null;
    }
1114885
protected function isIdSet()
    {
        if (isset($this->data[$this->id_name])) {
            if (filter_var($this->data[$this->id_name], FILTER_VALIDATE_INT)) {
                return (int) $this->data[$this->id_name] > 0;
            }

            return mb_strlen(trim($this->data[$this->id_name])) > 0;
        }
        
        return false;
    }
706446
public function getId()
    {
        if (is_null($this->_id)) {
            $this->_id = md5(microtime() . mt_rand());
        }

        return $this->_id;
    }
1127961
public function nextId()
    {
        $timestamp = floor(microtime(true) * 1000) - $this->epochTimeStamp;
        if($timestamp > $this->maxTimeStamp) {
            throw new Exception('Snowflake: TimeStamp overflow. Unable to generate any more IDs');
        }
        
        $machine = $this->machineId;
        if($machine < 0 || $machine > 1023) {
            throw new Exception('Snowflake: Machine ID out of range');
        }
        $sequence = mt_rand(0, 4095);
        if(PHP_INT_SIZE == 4) {
            return $this->makeId32($timestamp, $machine, $sequence);
        } else {
            return $this->makeId64($timestamp, $machine, $sequence);
        }
    }
1051335
protected function createId()
	{
		$id = 0;

		while (strlen($id) < 32)
		{
			$id .= mt_rand(0, mt_getrandmax());
		}

		return md5(uniqid($id, true));
	}
712612
public function recordExists($id)
    {
        if (is_object($id)) {
            return true;
        }
        if (is_numeric($id) or $this->shouldBeNumber($id)) {
            return $this->findById($id, true);
        }
        if (is_string($id)) {
            return $this->findByIdentifier($id, true);
        }
    }
401441
function getId()
    {
        if( $this->key )
            return $this->key;
        if( $this->long )
            return $this->long;
        if( $this->short )
            return $this->short;
    }
1130497
public function getId()
    {
        if (isset($this->ids[$this->namespace])) {
            return $this->ids[$this->namespace];
        } else {
            return (int) $this->getRecord()->get('id');
        }
    }
174980
public function nextId()
    {
        $timestamp = time() - static::BASE_TIME;

        if ($this->lastTimestamp >= $timestamp) {
            $timestamp = $this->lastTimestamp;

            $sequence = ++ $this->sequence;

            if ($sequence > 0x7ff) {
                $this->lastTimestamp = ++ $timestamp;

                $sequence = $this->sequence = 0;
            }
        } else {
            $this->lastTimestamp = $timestamp;

            $sequence = $this->sequence = 0;
        }

        return ($timestamp << 32) | $this->mask | ($sequence & 0x7ff);
    }