我有几个实体:
实体用户检查:
#[Id]
#[Column(type: 'guid')]
public string $id;
#[Column(type: 'guid')]
public string $userId;
#[Column(type: 'guid')]
public string $checkId;
#[Column(type: 'string')]
public string $status;
#[Column(type: 'datetime_immutable')]
public DateTimeImmutable $createdAt;
#[Column(type: 'datetime_immutable', nullable: true)]
public ?DateTimeImmutable $finishedAt;
实体检查:
#[Id]
#[Column(type: 'guid')]
public string $id;
#[Embedded(class: FullName::class)]
public FullName $fullName;
#[Column(type: 'datetime_immutable')]
public DateTimeImmutable $birthDay;
可嵌入的全名:
#[Column(type: 'string')] public string $name,
#[Column(type: 'string')] public string $surname,
#[Column(type: 'string')] public string $patronymic)
我正在尝试按姓名(姓名、姓氏、父名)进行搜索 我试图连接的名字、姓氏和父名。
我尝试按名称进行搜索:
$qb = $this->createQueryBuilder('user_check');
$qb
->leftJoin(Check::class, 'check', Join::WITH, 'user_check.id = check.id')
->andWhere('LOWER(CONCAT(check.full_name.name, check.full_name.surname, check.full_name.patronymic)) LIKE :searchTerm')
->setParameter('searchTerm', mb_strtolower('%' . $query['query'] . '%'));
有什么问题,我如何按名字搜索(连接名字、姓氏和父名)。如果我没有直接连接,而只有 checkId