Code problem when fetching objects

Author Message

Eirik Alfstad Johansen

Friday 19 November 2004 7:00:30 am

Hi guys,

The following code is supposed to fetch a list of objects where the object attribute value of the class attribute id 505 contains the value "ARBEID". However, instead, it fetches all the objects under the $parentNodeID. Are there any obvious syntax errors in the code?

$fetchObject = new eZContentFunctionCollection;
$products = $fetchObject->fetchObjectTree(
$parentNodeID, array(), false, 
false, 4, 'le', false, array( 'or', array( 505, '=', 'ARBEID' )), 
false, false, false, false, null, true);

Thanks in advance !

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Lazaro Ferreira

Friday 19 November 2004 8:43:31 am

Hi,

Change change attributefilter code to :

array( array( 505, '=', 'ARBEID' ) )

it should work

Lazaro
http://www.mzbusiness.com

Eirik Alfstad Johansen

Friday 19 November 2004 9:35:08 am

Nope, that didn't do the trick. Any other ideas?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Lazaro Ferreira

Friday 19 November 2004 10:09:24 am

Hi,

I just can confirm you that a code like this works perfectly here :


$attribute_filter = array( array( 330,'=', $myvalue ) );   
							
$matchingObjectList = array();

$matchingObjectList =& eZContentFunctionCollection::fetchObjectTree( 
                                                                     $parentNodeID, $sortBy, $offset, $limit, 
                                                                     $depth, $depthOperator,
                               		                       $classID, $attribute_filter, 
							     $extended_attribute_filter, $class_filter_type, 
							     $class_filter_array,
                                    $groupBy, $mainNodeOnly, $asObject );

Of course every variable was properly set before

The only difference we got is that we use php

::

operator instead of creating a new instance of eZContentFunctionCollection, but this couldn't be a problem

Lazaro
http://www.mzbusiness.com

Eirik Alfstad Johansen

Saturday 20 November 2004 2:53:33 am

Hi Lazaro,

I dont think the 'or' part of the attribute filter is the problem as I use it in several other places of the script where it works as supposed to. Any other ideas?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Eirik Alfstad Johansen

Monday 22 November 2004 6:44:55 am

Bump. Anyone?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Kåre Køhler Høvik

Monday 22 November 2004 7:46:09 am

This looks wrong.

array( 'or', array( 505, '=', 'ARBEID' ))

You need 2 parameters after the 'or'.

You can also try to turn on debug output and SQL output. Try to locate the SQL statement this query generates, and paste it here.

Kåre Høvik

Lazaro Ferreira

Monday 22 November 2004 9:09:24 am

Hi

I'm agree with Kare

I had though in the same way when I suggest you to change your filter to

array( array(505,'=','ARBEID') )

, because this way your are implicitly using

AND

logic in your SQL query, instead

OR

logic.

In any case it seems to me that you should use AND logic instead OR logic to get what you want

Lazaro
http://www.mzbusiness.com

Eirik Alfstad Johansen

Monday 22 November 2004 10:35:10 am

Thanks for your helpful advice, guys. After some extensive bug hunting and printing SQL queries, it turns out that the problem wasn't in the code I posted, but rather in the custom datatype upon which the attribute I was searching was built. The datatype missed the following method:

function &sortKeyType()
    {
        return 'string';
    }

...causing the SQL query to search the sort_key_int field of the db table instead og sort_key_string.

Not an easy one to spot, that one. Thanks again for all your help!

PS. Kåre: You mentioned turning SQL output on? Is there an INI switch for this? If so, where is it located?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Ole Morten Halvorsen

Monday 22 November 2004 11:14:11 am

Eirik,

file: settings/site.ini

[DatabaseSettings]
SQLOutput=enabled

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

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 19 2025 21:30:43
Script start
Timing: Jan 19 2025 21:30:43
Module start 'layout'
Timing: Jan 19 2025 21:30:43
Module start 'content'
Timing: Jan 19 2025 21:30:44
Module end 'content'
Timing: Jan 19 2025 21:30:44
Script end

Main resources:

Total runtime0.8965 sec
Peak memory usage4,096.0000 KB
Database Queries82

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0091 589.1641152.6250
Module start 'layout' 0.00910.0038 741.789139.4609
Module start 'content' 0.01290.8820 781.2500698.4141
Module end 'content' 0.89480.0016 1,479.664124.1563
Script end 0.8964  1,503.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3546160.0002
Check MTime0.00130.1442160.0001
Mysql Total
Database connection0.00320.353610.0032
Mysqli_queries0.816091.0276820.0100
Looping result0.00070.0767800.0000
Template Total0.865796.620.4329
Template load0.00190.212820.0010
Template processing0.863896.359220.4319
Template load and register function0.00010.012310.0001
states
state_id_array0.00060.062210.0006
state_identifier_array0.00100.114420.0005
Override
Cache load0.00170.1860600.0000
Sytem overhead
Fetch class attribute can translate value0.00050.052540.0001
Fetch class attribute name0.00100.1076120.0001
XML
Image XML parsing0.00240.271240.0006
class_abstraction
Instantiating content class attribute0.00010.0061160.0000
General
dbfile0.00230.2554210.0001
String conversion0.00000.001040.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/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: 48
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs