fetching objects from php based on attributes

Author Message

Patrice Fortin

Tuesday 08 May 2007 6:32:34 pm

I people,
I want to create a function that can be called from a template which fetches events for a single month in some/all calendars in a site. The function will return a array of arrays having each day as an element to be able to display it like webcalendar (displaying event names in each table cell with links or popup on mouseover).

Anyway, here is where I'm having trouble: I don't know how to fetch objects depending on attributes. I can easily do it from a template, but I can't figure out how to do it from a php function.

Here is a simplified fetch that would be enough for testing. Logically, this should return nothing, but it returns the same thing, no matter if the "array( 'or', array('event/from_time', '<', 0) )" condition is there:

        $events =  eZPersistentObject::fetchObjectList( eZContentObject::definition(),
                                                                   null, 
                                                                   array( 'contentclass_id' => 30,
                                                                          array( 'or', array('event/from_time', '<', 0) ) ),
                                                                   false,
                                                                   false,
                                                                   true );

What is incorrect in my condition parameter ?

Kristof Coomans

Tuesday 08 May 2007 11:26:20 pm

Hi Patrice

I think you are using the wrong function for what you are trying to do. Use eZContentObjectTreeNode::subTree or instead. &#321;ukasz wrote a nice blog article in which you can find a few examples: http://serwatka.net/en/blog/fetching_ez_publish_content_objects_with_php.

The conditions parameter to eZPersistentObject::fetchObjectList is documented well with Doxygen (the API docs are at http://pubsvn.ez.no/doxygen/3.9/html/index.html ).

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

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 14:58:58
Script start
Timing: Jan 18 2025 14:58:58
Module start 'layout'
Timing: Jan 18 2025 14:58:58
Module start 'content'
Timing: Jan 18 2025 14:58:58
Module end 'content'
Timing: Jan 18 2025 14:58:58
Script end

Main resources:

Total runtime0.0164 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 588.0469152.6406
Module start 'layout' 0.00580.0029 740.687539.4766
Module start 'content' 0.00870.0059 780.164189.4922
Module end 'content' 0.01460.0018 869.656330.3047
Script end 0.0164  899.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002515.3418140.0002
Check MTime0.00106.2687140.0001
Mysql Total
Database connection0.00106.036110.0010
Mysqli_queries0.002112.745330.0007
Looping result0.00000.085810.0000
Template Total0.00159.310.0015
Template load0.00084.787310.0008
Template processing0.00074.444210.0007
Override
Cache load0.00063.548710.0006
General
dbfile0.00138.219780.0002
String conversion0.00000.059640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs