Forums / General / fetch on object relations

fetch on object relations

Author Message

gareth eke

Tuesday 25 November 2008 3:38:35 am

hi all, apologies in advance for asking such a basic question, but i'm having trouble with this fetch....

{def $score_count = fetch( 'content', 'tree_count', hash( 'parent_node_id', 2,

'class_filter_type', 'include', 'class_filter_array', array( '47' ),

'attribute_filter', array( array( 'score/player_name', '=', 'John Doe' ) )

) )}

where the 'player_name' attribute is an Object relation

i can't seem to return any results, have i missed something regarding object relations?

thanks

Arnaud Lafon

Tuesday 25 November 2008 4:56:17 am

Hi,

First, as far as I know, attribute_filter will only work with the Object Relation datatype but It won't work with the Object Relation<b>s</b> one. Are you using the correct datatype ?

Then, If I read the example 12 on this page http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/list, you should use the object ID instead of the related object name.

Hope this helps

Arnaud

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

gareth eke

Tuesday 25 November 2008 5:12:30 am

thanks for the reply Arnaud, yes, just to confirm i am using the Object relation, and not relations...my post was a bit ambiguous

gareth eke

Tuesday 25 November 2008 5:41:09 am

doh!

how typical is that, i couldn't solve this for weeks, so worked on other things instead. Then as soon as i post to the forum i accidentally stumble on how to fetch the results i want, using $node.object.id as below!

thanks to Arnaud and anyone else who took any time considering my question

Gareth

{def $score_count = fetch( 'content', 'tree_count', hash( 'parent_node_id', 2,

'class_filter_type', 'include', 'class_filter_array', array( '47' ),

'attribute_filter', array( array( 'score/player_name', '=', $node.object.id ) )

) )}

Arnaud Lafon

Tuesday 25 November 2008 7:23:21 am

You're welcome! :)

Looking for information about SQLI ?
Looking for a new job in Paris ?
Please contact me at alafon [at] sqli [dot] com

Simon Boyer

Wednesday 13 July 2011 8:05:11 am

Hi,

I added an extension to fetch objects with object relation(s) filter :

http://projects.ez.no/oworfilter

This extension provides an extended attribute filter to use with fetch functions.

--
Developer at Open Wide