fetchObject(..); please help!

Author Message

Clemens T

Wednesday 28 September 2005 2:13:28 am

Hey all,
I have the following situation:

a contentobject myUser has normal UserClass attributes, but it has an aditional 'old_id' as attribute. I'd like to know how to make a function:

function getUser($oldId){
     //implementation goes here
     return $newID
}

I think i need to use eZPersistentObject::fetchObject, although I'm not sure about this, can someone please help me?
Thanks a lot!
Clemens

Clemens T

Wednesday 28 September 2005 3:27:31 am

Here's my first attempt:

//grab the user based on the oldid (which is unique)
$cObject=eZPersistentObject::fetchObject(ezUser::definition(),
                                           		null,
                                           		array('oldid'=>$oldId),
                                           		$asObject=true,
                                           		null,
                                           		null);

//print ' object' if succeeded
print($cObject);

It returns the following:

Notice: Only variable references should be returned by reference in /opt/guide/www.blaat.com/ezpublish-3.7.0rc2/lib/ezutils/classes/ezsys.php on line 677

So it doesn't work

Anyone.. anyting?

Clemens T

Wednesday 28 September 2005 7:46:55 am

Or should I use 'remote_id'?

What are the possibilities of this variable? How to use it, because I'm trying to import a lot of users /other data from my old site into ezPublish!

Thanks,
Clemens

Clemens T

Wednesday 28 September 2005 8:51:58 am

GOT IT!
I'll post my code here later on..

Clemens T

Saturday 01 October 2005 4:02:48 am

You've got to use the remote_id of a contentobject!

...
    $contentObject->setAttribute( 'remote_id', $oldid);    
	$contentObject->store();
...
//$remote_id = old user_id
function getNewUserID($remote_id){	
    $myTmpObject=eZPersistentObject::fetchObject( eZContentObject::definition(), null,
                                                        array( 'remote_id' => $remote_id) );
	if(is_object($myTmpObject))
    	return $myTmpObject->attribute('id');
    else 
    	return null;
}

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 04:42:39
Script start
Timing: Jan 19 2025 04:42:39
Module start 'layout'
Timing: Jan 19 2025 04:42:39
Module start 'content'
Timing: Jan 19 2025 04:42:40
Module end 'content'
Timing: Jan 19 2025 04:42:40
Script end

Main resources:

Total runtime0.7870 sec
Peak memory usage4,096.0000 KB
Database Queries61

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0097 590.2656152.6250
Module start 'layout' 0.00970.0087 742.890639.4453
Module start 'content' 0.01840.7673 782.3359463.7969
Module end 'content' 0.78580.0012 1,246.132812.1641
Script end 0.7869  1,258.2969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4965160.0002
Check MTime0.00150.1911160.0001
Mysql Total
Database connection0.00180.224810.0018
Mysqli_queries0.731092.8910610.0120
Looping result0.00050.0678590.0000
Template Total0.741394.220.3707
Template load0.00230.295120.0012
Template processing0.739093.902920.3695
Template load and register function0.00020.019910.0002
states
state_id_array0.00110.141110.0011
state_identifier_array0.00120.146120.0006
Override
Cache load0.00200.2550290.0001
Sytem overhead
Fetch class attribute can translate value0.00050.060610.0005
Fetch class attribute name0.00110.144650.0002
XML
Image XML parsing0.00010.011710.0001
class_abstraction
Instantiating content class attribute0.00000.001650.0000
General
dbfile0.00080.1001100.0001
String conversion0.00000.001540.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/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: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs