stibiumz / phalcon.eager-loading

Solves N+1 query problem in Phalcon Model
The Unlicense
36 stars 24 forks source link

Loading child of empty parent throw Exception #4

Closed Wayne-Wen closed 9 years ago

Wayne-Wen commented 9 years ago

@stibiumz In our development, I got an error ---- " [ERROR] Syntax error, unexpected EOF". I used xdebug to track what happened and found that the query builder try to execute with empty bind values in "inWhere" method. This Error is located at line 203 in EagerLoading\EagerLoad.php.

In our case, the "$subjectSize" is equal 0. We have follow three models: "Invoice","Payment","Method". Each invoice have many payments, and each payment have one method. In my code: $inv=Invoice::findFirstById("1"); then I tried to load payment and method using: $inv->load("Payment.Method"); For invoice 1, there are not any payment yet in database. So I expected the result of $inv->payment should be null when I called $inv->load("Payment.Method").

Could anyone fix this?

stibiumz commented 9 years ago

Thanks for reporting. I think it's fixed, try it