empty non-existent object in RecordSet #143

Closed
eLod opened this Issue Sep 27, 2011 · 2 comments

Comments

Projects
None yet
3 participants

eLod commented Sep 27, 2011

Having 2 models like Customers hasMany Payments and doing

$customer = Customers::find('first', array('conditions' => array('Customers.id' => $this->request->id), 'with' => 'Payments'));

will work as expected if any Payments can be found. However when there's no related data count($customer->payments) will return 1 and $customer->payments->data() will return an array that has an array as the first item with all the model's attributes with values NULL, e.g. array(1) { [0]=> array(4) { ["id"]=> NULL ["customer_id"]=> NULL ["amount"]=> NULL ["added"]=> NULL } }.

By the way i had to set conditions explicitly, because doing find($this->request->id, array('with' => 'Payments')) would fail because of id column is ambiguous (it should be prefixed with the model's alias).`

Member

daschl commented Sep 27, 2011

@eLod this seems to be a duplicate of #140

Owner

nateabele commented Sep 27, 2011

Duplicate.

nateabele closed this Sep 27, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment