参数无效:查询中未定义令牌帐户

I have two query builders defined.

First: Returns all accounts of an user.

Seconds: Returns all user transactions by account.

First:

public function getAccountsList($user)
{
    return $this->getAccountRepository()
        ->createQueryBuilder('a')
        ->select('a')
        ->where('a.user = :user')
        ->setParameter('user', $user)
        ->getQuery()
        ->getResult();
}

Second:

 public function  getTransactionsList($user)
{
    $accounts = $this->getAccountsList($user);

    $query = $this->getTransactionRepository()
        ->createQueryBuilder('t')
        ->select('t')
        ->where('t.account IN (:accounts)')
        ->setParameter('account', $accounts)
        ->getQuery()
        ->getResult();

    return $query;
}

First works perfect but second throws an error:

Invalid parameter: token account is not defined in the query

How to fix it?

token account is not defined in the query

That mean ->setParameter('account', ...) is anywhere is the query

in your ->where you have set the token :accounts with the S and the end, typo error

Correct answer is

public function  getTransactionsList($user) {
    $accounts = $this->getAccountsList($user);

    $query = $this->getTransactionRepository()
        ->createQueryBuilder('t')
        ->select('t')
        ->where('t.account IN (:accounts)')
        ->setParameter('accounts', $accounts)
        ->getQuery()
        ->getResult();

    return $query;
}

You have a typo in account parameters

 public function  getTransactionsList($user)
{
    $accounts = $this->getAccountsList($user);

    $query = $this->getTransactionRepository()
        ->createQueryBuilder('t')
        ->select('t')
        ->where('t.account IN (:accounts)')
        ->setParameter('account', $accounts)
        ->getQuery()
        ->getResult();

    return $query;
}

As you can see...

->where('t.account IN (:accounts)')

->setParameter('account', $accounts)

One is accounts and the other is account. Should be:

 public function  getTransactionsList($user)
{
    $accounts = $this->getAccountsList($user);

    $query = $this->getTransactionRepository()
        ->createQueryBuilder('t')
        ->select('t')
        ->where('t.account IN (:accounts)')
        ->setParameter('accounts', $accounts)
        ->getQuery()
        ->getResult();

    return $query;
}