BadMethodCallException:错误的参数数量

时间:2019-01-22 12:17:03

标签: php phalcon

由于我是Phalcon框架的新手,所以没有找到解决我问题的方法。这是我要使用的查询:

    $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();

它给了我BadMethodCallException: Wrong number of parameters。我在这里做什么错了?

2 个答案:

答案 0 :(得分:2)

->columns()需要一个参数,一个字符串或数组。

尝试一下

$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();

答案 1 :(得分:0)

好了,我改变了解决方法:

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

->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')

它对我有用。除了接受单个参数的列之外,我还必须编写Withdrawals的完整路径,以使其起作用。