php - 按姓名、姓氏和父名搜索
问题描述
我有几个实体:
实体用户检查:
#[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
解决方案
推荐阅读
- libreoffice - 如何在 Libreoffice Writer 中创建条件文本?
- python - 如何在 Python 中检查文件是否包含 SFTP 服务器上的字符串?
- ssl - 如何在 IBm Cloud CloudFoundry 应用程序中激活证书?
- css - 圆角时如何调整下拉列表中的滚动条?
- java - mysql 10.1.21-MariaDB 的方言类名称是什么
- python - zapier - IOError:[Errno 30] 只读文件系统:'products.cvs'
- excel - 循环通过宏调用的 Excel 2013 宏仅适用于一张工作表
- sql - Hadoop SQL - Impala 和计算字段
- reactjs - React-Table 从状态打开子组件
- reactjs - 如何使用 TypeScript 正确键入 React 连接的组件