[TYPO3-mvc] How to get first object of an 1:n relation

Thomas Kieslich thomas.kieslich at gmail.com
Wed Jun 22 14:26:47 CEST 2011


Sorry, you're right.
I should more read before i write ;-)

Thomas

Am 22.06.2011 14:09, schrieb Claus Due:
> Hi Thomas,
>
> What you write does NOT work for ObjectStorage.
>
> QueryResult supports getFirst(), ObjectStorage does not - hence: $place->getImages()->toArray() (optionally, shift the first child off the array).
>
> I do agree, though. If only one image is needed, only one image should be pulled from DB. However, if $place is already loaded and needed then array_shift() on ->toArray() result is just fine  - and it does seem like this is true according to the description/varnames.
>
> --
>
> Med venlig hilsen / Kind regards
>
> Claus Due
> Code Monkey
> --
> Wildside A/S
> Katrinebjergvej 113, DK-8200 Århus N
> tlf. 86 12 64 65
> http://www.wildside.dk
>
> On Jun 22, 2011, at 1:55 PM, Thomas Kieslich wrote:
>
>> $images = $place->getImages()->getFirst();
>


More information about the TYPO3-project-typo3v4mvc mailing list