PHP Classes

File: docs/db-storage.rst

Recommend this page to a friend!
  Packages of A. B. M. Mahmudul Hasan   UID (UUID, ULID, Snowflake, Sonyflake, Nano, CUID, KSUID, XID, TBSL)   docs/db-storage.rst   Download  
File: docs/db-storage.rst
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: UID (UUID, ULID, Snowflake, Sonyflake, Nano, CUID, KSUID, XID, TBSL)
Generate, parse, validate unique identifiers
Author: By
Last change:
Date: 10 days ago
Size: 1,057 bytes
 

Contents

Class file image Download
Database Storage ================ UID includes ``Infocyph\\UID\\DbStorage`` with recommendations for UUID, ULID, and Snowflake. UUID ---- - MySQL: prefer ``BINARY(16)`` for compact indexes. - PostgreSQL: prefer native ``UUID`` type. - Ordering: ``UUIDv7`` provides better insertion locality than ``UUIDv4``. ULID ---- - MySQL: ``CHAR(26)`` (readable) or ``BINARY(16)`` (compact/index-friendly). - PostgreSQL: ``CHAR(26)`` or ``BYTEA`` depending on interoperability. - Ordering: canonical ULID text is chronologically sortable. Snowflake and Sonyflake ----------------------- - MySQL: ``BIGINT UNSIGNED``. - PostgreSQL: ``BIGINT`` if range is safe, otherwise ``NUMERIC(20,0)``. - Ordering: numeric sort equals time sort. TBSL ---- - Use ``CHAR(20)`` for canonical uppercase hex. - Use ``BINARY(10)`` when compactness matters. Programmatic Access ------------------- .. code-block:: php <?php use Infocyph\UID\DbStorage; $uuidAdvice = DbStorage::uuid(); $ulidAdvice = DbStorage::ulid(); $snowflakeAdvice = DbStorage::snowflake();