Hi Tobias
Tobias Schlitt wrote:
> To summarize the daily usage of the new features in short:
>
> Using identity mapping
> ======================
>
> Change your current code
>
> $session = new ezcPersistentSession( ... );
>
> to
>
> $innerSession = new ezcPersistentSession( ... );
> $session = new ezcPersistentIdentitySession(
> $innerSession,
> new ezcPersistentIdentityMap()
> );
>
> and your existing code will enjoy the flavor of the identity map.
>
No problems here :-)
> Simple relation prefetching
> ===========================
>
> Change your current code
>
> $q = $session->createFindQuery( 'User' );
> $q->orderBy( 'name' );
>
> $users = $session->find( $q, 'User' );
>
> foreach ( $users as $user )
> {
> $books = $session->getRelatedObjects( $user, 'Book' );
> foreach ( $books as $book )
> {
> // Fetch authors...
> }
> }
>
> to
>
> $q = $session->createFindQuery( 'User' );
> $q->orderBy( 'name' );
>
> $users = $session->findWithRelatedObjects(
> $q,
> 'User',
> array(
> 'Book' => array(
> 'Author' => true
> )
> )
> );
>
> // ... Foreach loops here ...
>
>
> and the related objects are fetched with a join instead of single selects.
>
And where do the Book and Author objects go? I suppose they remain in
the identity map until they are fetched. And how do you get them from
the identity map? Do you still have to use e.g.
$session->getRelatedObjects( $user, 'Book' ); ?
I must say that this looks easier than what I could gather from the
design docs and all the Set stuff.
Another question I have is about performance. All related objects are
fetched, so this could potentially get thousands of objects in memory.
Have there been any tests (or are they planned) to see how the identity
map system copes with loads of objects? It would be nice to get a rough
idea about the possible limits, that of course also depend on server
configuration. But still, a reference would be nice.
Thanks for clearing this up with some code examples!
Regards,
Hans
--
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components