Hi Christoph,

On 04/24/2010 11:08 AM, Christoph René Pardon wrote:

> no, i only use one of both methods. Both together make no sense.
> 
> If i try $ezcSession->findWithRelations($query) the following exception
> is thrown:
> 
> Fatal error: Call to private method
> ezcPersistentSessionIdentityDecorator::findWithRelations() from context
> 'Admin_Service_User' in
> /var/www/YelaCMS/public/YelaCMS/components/admin/services/User.php on
> line 111
> 
> Where $result = $ezcSession->findWithRelations($query) is on line 111.

a, right. Didn't have the API fully in my mind anymore. Looking it up,
this is logical.

$ezcSession->find( $query );

is the way to go.

> You can see in the following example, that only the columns/attributes
> from table one were fetched. But i need ALL attributes from ALL related
> tables.

Ah, now I get your problem. Well, this is not the way it is meant to be
used.

The find() method only returns the root objects you intended to fetch.
To access the related objects you need to call

$ezcSession->getRelatedObjects( $rootObject, 'ClassOfRelatedObject' );

This will then return the desired objects from the cache.

In your case that would be something like:

$users = $ezcSession->find( $query );

foreach ( $users as $user )
{
    $infos = $ezcSession->getRelatedObjects(
        $user,
        'Yela_Persistence_Users_Informations'
    );
    // ...
}

The desired objects are fetched by the find() call, but not returned.
Calling getRelatedObjects() returns them from the internal object cache
in the session.

HTH, cheers,
Toby
-- 
Tobias Schlitt         tob...@schlitt.info       GPG Key: 0xC462BC14
a passion for php                     http://schlitt.info/opensource
eZ Components are Zeta Components now!          http://bit.ly/9S7zbn
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to