Forums / Developer / fetchObject(..); please help!

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;
}

eZ debug

Timing: Jan 19 2025 01:13:18
Script start
Timing: Jan 19 2025 01:13:18
Module start 'content'
Timing: Jan 19 2025 01:13:19
Module end 'content'
Timing: Jan 19 2025 01:13:19
Script end

Main resources:

Total runtime0.9092 sec
Peak memory usage4,096.0000 KB
Database Queries198

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.9453180.8438
Module start 'content' 0.00540.7824 769.7891468.8750
Module end 'content' 0.78780.1214 1,238.6641337.4766
Script end 0.9092  1,576.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4258210.0002
Check MTime0.00140.1595210.0001
Mysql Total
Database connection0.00070.073310.0007
Mysqli_queries0.846193.06021980.0043
Looping result0.00180.20321960.0000
Template Total0.881096.920.4405
Template load0.00210.234720.0011
Template processing0.878996.658320.4394
Template load and register function0.00020.024210.0002
states
state_id_array0.00130.146110.0013
state_identifier_array0.00150.159720.0007
Override
Cache load0.00180.1974290.0001
Sytem overhead
Fetch class attribute can translate value0.00130.139320.0006
Fetch class attribute name0.00100.111450.0002
XML
Image XML parsing0.00030.035320.0002
class_abstraction
Instantiating content class attribute0.00000.001150.0000
General
dbfile0.00240.2585210.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs