[TYPO3-mvc] findBy[Property] problems

Franz Koch typo3.RemoveForMessage at elements-net.de
Fri Feb 11 22:39:32 CET 2011


Hey Lorenz,

> Seems to be a pretty rough way for me to get into the extbase flow :-).
>
> I have an extension with an addressRepository that uses the tt_address
> table. Saving new addresses works fine.
>
> But when inserting a new address I would like to check if it's a
> duplicate. So I use this magic findBy[property] method:
>
> $existing = $this->addressRepository->findByEmail('mail at dress.com')
>
> But the only thing I get back is the following warning:
>
> You should never see this warning. If you do, you probably used PHP
> array functions like current() on the
> Tx_Extbase_Persistence_QueryResult. To retrieve the first result, you
> can use the getFirst() method.

How are you processing $existing? $existing is no longer an array - as 
of extbase 1.3.0 it's an object, so you can't use stuff like 
"current($existing)" on it.

If you expect only one result or none at all, give 
$this->addressRepository->findOneByEmail('...') a try.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list