How to do a fetch with PHP

Author Message

Felix Laate

Thursday 09 March 2006 2:20:16 am

Hi all,

I want to fetch the newest object of a certain class in a certain folder, and I need to do it with PHP as it's part of a module.

Let's say I have a content class "letter" with ID=21, and I have a bunch of objects of this class that are published under a certain folder. Now I need to fetch the newest one.

Any help is helpful and appreciated!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Łukasz Serwatka

Thursday 09 March 2006 2:30:57 am

Hi Felix,

Use eZContentObjectTreeNode

$parentNodeID = 123;

$objects =& eZContentObjectTreeNode::subTree(  array(
'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'letter' ),
'SortBy' => array( 'published', false ),
),
$parentNodeID
);

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Felix Laate

Thursday 09 March 2006 3:24:25 am

Hi Lukasz,

thanx, that did the trick.. now I only need to figure out how to get the attributes of the object.. any advice?

:-) Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Łukasz Serwatka

Thursday 09 March 2006 3:42:45 am

Loop throw $objects array

foreach( $objects as $object )
{
    $dataMap =& $object->attribute( 'data_map' );
   
    //image attribute
    $image = $dataMap['image']->content();
 
    // email attribute
    $email = $dataMap['email']->content();
    var_dump($dataMap);
}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Felix Laate

Thursday 09 March 2006 4:07:49 am

Hi again,

great! Thank you very much!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:33:19
Script start
Timing: Jan 18 2025 19:33:19
Module start 'layout'
Timing: Jan 18 2025 19:33:19
Module start 'content'
Timing: Jan 18 2025 19:33:20
Module end 'content'
Timing: Jan 18 2025 19:33:20
Script end

Main resources:

Total runtime1.2152 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 589.0313152.6250
Module start 'layout' 0.00470.0032 741.656339.4453
Module start 'content' 0.00791.2059 781.1016564.6406
Module end 'content' 1.21380.0014 1,345.742216.1641
Script end 1.2152  1,361.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2724160.0002
Check MTime0.00140.1111160.0001
Mysql Total
Database connection0.00060.047110.0006
Mysqli_queries1.157595.2512630.0184
Looping result0.00060.0473610.0000
Template Total1.186397.620.5932
Template load0.00220.181320.0011
Template processing1.184197.437920.5921
Template load and register function0.00010.009010.0001
states
state_id_array0.00070.058710.0007
state_identifier_array0.00170.139520.0008
Override
Cache load0.00170.1428280.0001
Sytem overhead
Fetch class attribute can translate value0.00080.068420.0004
Fetch class attribute name0.00100.085570.0001
XML
Image XML parsing0.00090.076520.0005
class_abstraction
Instantiating content class attribute0.00000.0018100.0000
General
dbfile0.00080.0649240.0000
String conversion0.00000.002440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs