spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

get -> with (a.k.a. Why doesn't get have the with-option?) #206

Closed marcelloh closed 7 years ago

marcelloh commented 7 years ago

I am trying: $result = $this->get($id)->with('relationtable'); the workaround I have: $result = $this->where(['id' =>$id])->with('relationtable'); But it gives me an array with 1 record, where the other option gives me an array with record-fields Why doesn't get have the with-option?

vlucas commented 7 years ago

You can use this to get a single record:

$result = $this->where(['id' =>$id])->with('relationtable')->first();

The get method will always return a single entity immediately.