• News
  • Developer information
  • Projects & contributions
  • Forum
  • Issue tracker
  • Open Funding
  • Security
  • User groups
  • Support
  • Store
  • Company

  • Path

    ez.no / exponential / documentation / development / libraries / ez template / operators / data fetch


    Data fetch

    These documentation pages are no longer maintained. Please visit the new documentation site.

    Execute

    Fetch

    Executes a given fetch operation, and returns the result. The parameters are the module name, the operation name,
    and a hash of operation parameters corresponding to the given function_name in kernel/[module_name]/function_definition.php.

    A few examples:
    Fetch the number of items in a list:

    {fetch('content','list_count',hash(parent_node_id,$node.node_id,
    
                                      sort_by,array(published,true()),
    
                                      class_filter_type,exclude,
    
                                      class_filter_array,array(1,24)))}

    Fetch a class: Returns the content class defined by class_id. E.g.

    {fetch('content','class',hash(class_id,4))}

    Fetch a class attribute: Returns one specific class attribute defined by attribute_id. The parameter version_id is optional (default 0) and defines the version of the attribute. E.g.

    {fetch('content','class_attribute',hash(attribute_id,140,version_id,0))}

    Fetch a class attribute list: Returns an array of all attributes for one class defined by class_id. The parameter version_id is optional (default 0) and defines the version of the attributes. E.g.

    {fetch('content','class_attribute_list',hash(class_id,4,version_id,0))}

    As of version 3.2 Exponential supports sorting on attribute level. This means that you can sort a list of objects by any attribute that supports sorting ( not all datatypes can be sorted ).

    Note: When doing attribute sorting Exponential will automatically filter on the class type.

    Example of sorting on class attribute id 1 ( which can e.g. be title of the article class, the number to use as attribute id can be found when you view the definition of a content class ).

    fetch('content',
    
           'list',
    
            hash( parent_node_id, $node.node_id,
    
                     sort_by,array(array('attribute',false(),1)),
    
                     limit,$page_limit,
    
                     offset,
    
                     $view_parameters.offset ))

    Note: In Exponential 3.2 ( rev 2868 ) you can filter the result on attribute values. The syntax for this is:

    fetch( 'content', 'list', 
    
             hash( parent_node_id,
     
    $node.node_id,                                          attribute_filter,
    
                                             array( 'or',
     array( 152, '=', 'abc' ), 
    
                                             array( 153,
     '=', '42' ) ) ) )

    Where 152 and 153 are class attribute ID's. They are visible on class edit. abc and 42 are the filter values. '=' is the filter type. Filter types/operators currently implemented are:

    = - equals
    
    != - not equals (requires 3.2-3, 3.3 or higher)
    
    < - less
    
    > - greater
    
    <= - less equal
    
    >= - greater equal

    attribute_filter also support using class and class attribute identifiers.

    fetch( 'content', 'list', 
    
             hash( parent_node_id, $node.node_id, 
    
                   attribute_filter,
     array( array( 'article/title', '=', 'abc' ) ) ) )

    Comments

    Is it possible to fetch objects by creator, or by "can_edit"?

    *subj*

    Can't query by one attribute and sort by another.

    I'm trying to run the following query

    fetch(content, list, hash(parent_node_id, 55,depth, 3,offset, $view_parameters.offset, limit, 1,attribute_filter, array('and', array('183', '=' ,content_version.data_map.short_name.content)), sort_by,array(attribute,true(),185)))

    and I keep ending up with no records. When reviewing the sql it appears that EZ is no capable of creating sql that queries one attribute and sorts by another.

    Also look here...

    attribute_filter ..

    fetch( 'content', 'list',
    hash( parent_node_id, $node.node_id, attribute_filter,
    array( 'or', array( 152, '=', 'abc' ),
    array( 153, '=', '42' ) ) ) )

    this query mean :
    where 152='abc' or 153=42
    ??!
    also can we use 'and' ?

    Contents

    Development

    Extensions
    Exponential datamodel
    Exponential tuning and stability
    Importing attribute data
    Kernel
    Libraries
        eZ xml
        eZ db
        eZ i18n
        eZ soap
        eZ template
           Basics
           Functions
           Operators
              Data fetch
              String handling
              Type handling
              Logical handling
              Arithmetics
              Control structure handling
              Array handling
              Image handling
              Miscellaneous
        eZ webdav
    Scripting
    Standards
    System overview
    Test Suite
    Using Doxygen to create API documenta...


    Created

    16/07/2003
    3:00:47 pm
    by Bård Farstad

    Last updated

    08/01/2004
    12:08:25 pm
    by Kåre Køhler Høvik

    Authors

    Bård Farstad
    Jan Borsodi
    Derick Rethans
    Kåre Køhler Høvik



    This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.