[TYPO3-english] Re: Re: Extbase -> reduce queries in m:m relations

Viktor Livakivskyi invisible.kinder at gmail.com
Thu Sep 12 15:44:43 CEST 2013


Hi, Robert

First of all, I want to apologize for misinformation. I wrote my last message a bit wrong. This part is not correct: "(becasue all of it's m:n relations will be created anyway)".

Once you put @lazy before any property in your model it get's substituted by TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage and this property is substituted with real object only in case it is needed.

Meaning, that you have such a simple structure:

class A {

protected $title;

/**
* @lazy
*/
protected $mmRelation;

..
}

Now, when your object is created, $title is filled with actual title, but $mmRelation is NOT filled with mm relations, but substituted with LazyObjectStorage.

Later you call ->getTitle() or {object.title} and still have LazyObjectStorage instead of $mmRelation.

BUT once you call ->getMmRealtion it will be substituted with real MM relation and objects initiated.

> Please let me clarify:
> 
> 1. There is no way to tell a controller / a repository which fields to 
> use? (Except by using statements, which are not compatible with flow)

I'm not sure, if you can limit it by controller or repository. Maybe, someone else, can help here, but as I understood, availability of object's properties is defined by view. So, if you use {object.title} - getTitle() will be called.


> 2. If I use lazy, should the fluid debugger show less fields in a 
> "property object"? (Because in my case it does not...)

No, becasue fluid debugger calls all ->get() methods and therefore lazy loading makes ni sence here.


> 3. Just jumping to my mind: if using statements, what is the more 
> optimized way to go: joins or subselects?

Sorry, but can't help you here...

Btw, a good advise to understand a logic of lazy loads is by using PHP debugger, like xdebug - so you can see state of all your object's properties in real time.


More information about the TYPO3-english mailing list