how to fetch class objects in php

Author Message

ludo thomas

Friday 01 July 2005 5:12:38 am

hi,

I'm looking for the code that allows you to make an array whith objects of a class.I just have the class id:305

I tried this, but it seems not to work fine:

$liste = eZContentObject::fetchList( true, array( 'contentclass_id' => 305 ) )

do someone have an other solution?
thx.

Harry Oosterveen

Friday 01 July 2005 8:59:18 am

When using the fetchList function, you have to use a string instead of an array for specifying the condition:

$liste = eZContentObject::fetchList( true, 'contentclass_id = 305' )

ludo thomas

Friday 01 July 2005 9:42:02 am

thanks harry,

but in my case, it seems not to work.
in the admin I have a 'prod' class, ID='305'
in this class there is 6 objects.

I want to put this 6 objects in an array.

First I tried:

$list=& eZContentClass::fetch( 305 );

After I tried your solution:

$liste=eZContentObject::fetchList( true, 'contentclass_id = 305' );

I receive more than 100 objects. why? I have empty the trash..

Help please..

perrin aybara

Saturday 02 July 2005 1:20:12 am

http://ez.no/community/forum/developer/how_to_fetch_objects_in_php_on_specified_attributes

Bruce Morrison

Saturday 02 July 2005 7:16:36 pm

I think you'll find the answers here http://pubsvn.ez.no/doxygen/classeZContentObject.html#a24 and here http://pubsvn.ez.no/doxygen/classeZPersistentObject.html#a9

$liste = eZContentObject::fetchList( true, array( 'contentclass_id' => 305 ) )

Should do the trick, however if you may need to add additional conditions. What you are after is all the CURRENT PUBLISHED objects of this class right?

$liste = eZContentObject::fetchList( true, 
  array( 'contentclass_id' => 305,
         'status'          =>  EZ_CONTENT_OBJECT_STATUS_PUBLISHED) 
);

Should get you this.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

ludo thomas

Monday 04 July 2005 1:02:13 am

YESSSS!!!

Thanks a lot bruce, that's a good job!
It was exactly what I needed for my newsletter,
I hope I could help You in the future..

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 31 2025 00:19:27
Script start
Timing: Jan 31 2025 00:19:27
Module start 'layout'
Timing: Jan 31 2025 00:19:27
Module start 'content'
Timing: Jan 31 2025 00:19:28
Module end 'content'
Timing: Jan 31 2025 00:19:28
Script end

Main resources:

Total runtime1.0612 sec
Peak memory usage8,192.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.1406151.2109
Module start 'layout' 0.00430.0031 739.3516220.7031
Module start 'content' 0.00741.0531 960.05474,561.2500
Module end 'content' 1.06040.0007 5,521.304715.8438
Script end 1.0612  5,537.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2983160.0002
Check MTime0.00120.1120160.0001
Mysql Total
Database connection0.00080.072610.0008
Mysqli_queries0.965190.9474700.0138
Looping result0.00060.0561680.0000
Template Total1.018796.020.5093
Template load0.00170.157420.0008
Template processing1.017095.833520.5085
Template load and register function0.00130.126610.0013
states
state_id_array0.00170.160210.0017
state_identifier_array0.00140.128720.0007
Override
Cache load0.00150.1398440.0000
Sytem overhead
Fetch class attribute can translate value0.00180.171040.0005
Fetch class attribute name0.00210.199190.0002
XML
Image XML parsing0.00490.464240.0012
class_abstraction
Instantiating content class attribute0.00000.0021110.0000
General
dbfile0.00430.4076270.0002
String conversion0.00000.000540.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 37
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs