Doctrine findBy boolean field返回无结果

时间:2018-01-18 22:31:41

标签: mysql symfony doctrine-orm doctrine symfony-3.2

最近,一段代码停止了工作。我没有对它做任何改动所以我不知道为什么。

以下是代码:

$invites = $this->vault_em->getRepository('AppBundle:Invite\LocalInvite')->findBy([
    'active' => true,
]);

现在,它返回一个空数组,即使LocalInvite记录的active = 1。

以下是学说映射:

/**
 * @ORM\Entity
 * @ORM\Table(name="invite")
 */
class LocalInvite extends Invite {

    //...

}

/** @ORM\MappedSuperclass */
abstract class Invite implements \JsonSerializable {

    /** @ORM\Column(type="boolean", options={"default": true}) */
    protected $active;

    //...

}

要进行调试,我从调试日志中复制了Doctrine正在执行的基础MySQL查询:

SELECT t0.id AS id_1, t0.email AS email_2, t0.active AS active_3, t0.location AS location_4, t0.cohort_leadership AS cohort_leadership_5, t0.timezone AS timezone_6, t0.date_record_created AS date_record_created_7, t0.date_record_deleted AS date_record_deleted_8, t0.date_restart AS date_restart_9, t0.date_start_invite AS date_start_invite_10, t0.employee_id AS employee_id_11, t0.first_name AS first_name_12, t0.corporate_client_name AS corporate_client_name_13, t0.client_id AS client_id_14, t0.landing_page_url AS landing_page_url_15, t0.user_id AS user_id_16, t0.recipient_id AS recipient_id_17 FROM invite t0 WHERE t0.active = true;

当我将该查询插入MySQL IDE时,它会返回结果。

为什么findBy没有返回结果?

1 个答案:

答案 0 :(得分:-2)

尝试按'AppBundle:Invite\LocalInvite'

更改LocalInvite::class