alextartan/doctrine-paginator-ramsey-binary-uuid

DoctrinePaginator 的扩展,使其在 id 为使用 ramsey/uuid 生成的二进制 uuid 时能够正常工作

1.0.3 2020-02-10 14:36 UTC

This package is auto-updated.

Last update: 2024-09-11 01:00:57 UTC


README

当对象的 id 是 uuid_binary 类型时,Doctrine 的 Paginator 无法返回对象。

这是因为数据库不会将 BINARY(16) 与字符串匹配。

解决方案是获取这些 id(它们被 UuidInterface::__toString 转换),并使用 UuidInterface::getBytes 返回它们。这允许在数据库级别进行适当的匹配。

当前构建状态

Build Status Coverage Status Mutation testing badge Scrutinizer Code Quality Downloads

安装

composer require alextartan/doctrine-paginator-ramsey-binary-uuid

使用

$repo = $this->em->getRepository(SomeEntity::class);
$query = $repo->createQueryBuilder('se')
              ->setMaxResults(2)
              // more stuff here
              ->getQuery();

$p = new BinaryUuidSafePaginator($query);

版本控制

此库遵循 semver