PHP : Copy relation list data from an object to another ?

Author Message

Lex 007

Tuesday 05 April 2005 5:52:54 am

Hi,

I need to copy the content of a relation list of an object to another object in a cronjob.

Basically, I have a custom class folder with a relation list of users. I would like to have the same relation lists in the custom class files in that folder.

What I can currenly do is get the relation list $contentObjectAttributes of the folder and the file. I tried to copy directly the "data_text" from one to the other ... Nice try but it didn't work :(

Should I copy the relations items one by one ? If so, how to do it ?

Any hint is appreciated.

I hope this time my message will be heard :)

Lex

Lex 007

Tuesday 05 April 2005 5:59:19 am

Nevermind, I made it : stupid mistake.

I was using

->content() 

instead of

->attribute("data_text")

Fabio Carissimi

Friday 30 June 2006 2:37:41 am

Hi,

I use the method described in this post : http://ez.no/community/forum/developer/add_object_relation_attribute_type_within_a_php_script :

$content = $objectRelationListAttribute->content();
$priority = 1;
foreach ( $objectsToRelate as $objectToRelate )
{
   $content['relation_list'][] = eZObjectRelationListType::appendObject( $objectToRelate->attribute( 'id' ), $priority, $objectRelationListAttribute );
   $objectRelationListAttribute->setContent( $content );
   $objectRelationListAttribute->store();
   $priority++;
}

but it does not work,
can you describe in more details your method which is working ?

Thanks for help

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

Main resources:

Total runtime1.0355 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0101 588.1406152.6406
Module start 'layout' 0.01010.0066 740.781339.4766
Module start 'content' 0.01671.0174 780.2578504.5469
Module end 'content' 1.03410.0014 1,284.804712.1094
Script end 1.0354  1,296.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3605160.0002
Check MTime0.00150.1442160.0001
Mysql Total
Database connection0.00170.164810.0017
Mysqli_queries0.968993.5753570.0170
Looping result0.00060.0584550.0000
Template Total0.988495.520.4942
Template load0.00260.249720.0013
Template processing0.985895.198720.4929
Template load and register function0.00020.021710.0002
states
state_id_array0.00100.097010.0010
state_identifier_array0.00150.142520.0007
Override
Cache load0.00200.1973260.0001
Sytem overhead
Fetch class attribute can translate value0.00060.058420.0003
Fetch class attribute name0.00110.104840.0003
XML
Image XML parsing0.00300.286320.0015
class_abstraction
Instantiating content class attribute0.00000.001050.0000
General
dbfile0.00430.4142160.0003
String conversion0.00000.003240.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/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: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs