eZ Community » Forums » Developer » how to fetch class objects in php

how to fetch class objects in php

how to fetch class objects in php

Friday 01 July 2005 2:12:38 pm - 5 replies


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?

Friday 01 July 2005 5:59:18 pm

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' )

Modified on Friday 01 July 2005 6:00:25 pm by Harry Oosterveen

Friday 01 July 2005 6:42:02 pm

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..

Saturday 02 July 2005 10:20:12 am


Sunday 03 July 2005 4:16:36 am

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.


Modified on Sunday 03 July 2005 4:28:24 am by Bruce Morrison

Monday 04 July 2005 10:02:13 am


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..


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from