[API] How to update an objetrelationlist field ?

Author Message

Sébastien Landeau

Wednesday 17 May 2006 10:52:44 am

I'm writing a batch inserting class from XML data (importing document from a thord party information system).
You'll read below the extract which is populating content object attributes...

The target eZContentObject has string, date, keyword and objectrelationlist fields.

I can achieve insertion for <i>string</i>, <i>date</i> and <i>keywords</i> field, but what about updating object relation list with with the target object's simple ID ?

---------------------------------------------------------------------------------

<i><b>
$itemType = $itemObj->get_attribute("type");
switch ($itemType) {
case _NOTES_XML_STRING_TYPE :
$ezItem->setAttribute('data_text', $fieldValue);
$cli->notice("Setting STRING value : " . $fieldValue);
break;
case _NOTES_XML_DATE_TYPE :
$dateElements = split("/", $fieldValue);
$dateSerial = mktime(0, 0, 0, $dateElements[1], $dateElements[0], $dateElements[2]);
$ezItem->setAttribute('data_int', $dateSerial);
$cli->notice("Setting DATE value : " . $dateSerial);
unset ($dateElements);
unset ($dateSerial);
break;
case _NOTES_XML_KEYWORDS_TYPE :
$keywordField = & $ezItem->attribute('content');
$cli->notice("Setting KEYWORDS value : " . $fieldValue);
$keywordField->initializeKeyword($fieldValue);
unset ($keywordField);
break;
}
$ezItem->store();
</b></i>

Gabriel Ambuehl

Wednesday 17 May 2006 11:25:32 am

AFAIK, objectrelationlist uses object relations with attributeid set, take a look at
http://pubsvn.ez.no/doxygen/classeZContentObject.html#a67 for that.

Visit http://triligon.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 11:43:31
Script start
Timing: Jan 18 2025 11:43:31
Module start 'layout'
Timing: Jan 18 2025 11:43:31
Module start 'content'
Timing: Jan 18 2025 11:43:31
Module end 'content'
Timing: Jan 18 2025 11:43:31
Script end

Main resources:

Total runtime0.8948 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 588.0469152.6406
Module start 'layout' 0.00840.0027 740.687539.4766
Module start 'content' 0.01110.8820 780.1641524.9453
Module end 'content' 0.89310.0017 1,305.10948.1250
Script end 0.8948  1,313.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4020160.0002
Check MTime0.00150.1730160.0001
Mysql Total
Database connection0.00160.182110.0016
Mysqli_queries0.839693.8235540.0155
Looping result0.00050.0588520.0000
Template Total0.857195.820.4285
Template load0.00200.221320.0010
Template processing0.855195.558820.4275
Template load and register function0.00020.021810.0002
states
state_id_array0.00180.202410.0018
state_identifier_array0.00080.090320.0004
Override
Cache load0.00170.1853370.0000
Sytem overhead
Fetch class attribute can translate value0.00060.067920.0003
Fetch class attribute name0.00160.179330.0005
XML
Image XML parsing0.00340.379520.0017
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00380.4221160.0002
String conversion0.00000.000840.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
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 11
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs