Search code examples
phpphalcon

BadMethodCallException: Wrong number of parameters


As I am new to Phalcon framework, I did not find the solution for my problem. Here is the query that I am trying to use:

    $withdraws = Withdrawals::query()
        ->columns('Withdrawals.cashboxId', 'Withdrawals.amount', 'Withdrawals.createdAt', 'Withdrawals.status', 'Withdrawals.serialNo', 'u.firstName', 'u.lastName')
        ->innerJoin('Shop\Domain\Clients\Models\Clients', 'Withdrawals.userId = u.id', 'u')
        ->where('Withdrawals.cashboxId = :cashboxId:', ['cashboxId' => $cashboxId])
        ->andWhere('Withdrawals.status = :status:', ['status' => 1])
        ->execute();

It gives me BadMethodCallException: Wrong number of parameters. What am I doing wrong here?


Solution

  • Well the solution was I changed:

    ->columns('Withdrawals.cashboxId', 'Withdrawals.amount', 'Withdrawals.createdAt', 'Withdrawals.status', 'Withdrawals.serialNo', 'u.firstName', 'u.lastName')
    

    to

    ->columns('Shop\Domain\Withdrawals\Models\Withdrawals.cashboxId, 
    Shop\Domain\Withdrawals\Models\Withdrawals.amount, 
    Shop\Domain\Withdrawals\Models\Withdrawals.createdAt, 
    Shop\Domain\Withdrawals\Models\Withdrawals.status, 
    Shop\Domain\Withdrawals\Models\Withdrawals.serialNo, 
    u.firstName, u.lastName')
    

    and it worked for me. Besides columns accepting single parameter, I also had to write the full path for Withdrawals in order to make it work.