Forums / Developer / fetchObject(..); please help!
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
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?
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
Wednesday 28 September 2005 8:51:58 am
GOT IT!I'll post my code here later on..
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; }