Hi Hans!

On 07/08/2008 04:02 PM Hans Melis wrote:
> Derick Rethans wrote:
> 8<-- snip --8<

>> I don't quite see why you need this set stuff... it seems all so 
>> complicated.

> That's my problem with this new proposed stuff for PO. While it sounds 
> nice in theory, for now it looks like an overcomplicated API.

Where exactky do you feel it's overcomplecated?

In fact, my recent changes make most things more easy, while it sources
out some parts we had in the design all the way into dedicated methods.

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.

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.

Only if you want to do more complex stuff (like fetching a subset of
books for a user instead of all), you need to write a bit more code,
which is not that much.

Where would you expect easier usage?

Thanks for your input,
Toby
-- 
Mit freundlichen Grüßen / Med vennlig hilsen / With kind regards

Tobias Schlitt (GPG: 0xC462BC14) eZ Components Developer

[EMAIL PROTECTED] | eZ Systems AS | ez.no
-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to