3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 690 Views |
-
stupid question

6 September 2010 at 4:04am Last edited: 6 September 2010 4:05am
Hi,
I'm feeling really stupid...
I have 2 unrelated dataobjects (DO1 and DO2).
DO1 needs some data from DO2 to perform the right behaviour (everything on the model-side, so no templating).What I have right now (in DO1) is:
function Address(){
$a = DataObject::get('DO2', "ID=1");
if($a){
$c = $a->City;
return $c;
}
}
I've been checking too many times for typos so I suspect there's something else I'm doing wrong.
But what...??? -
Re: stupid question

6 September 2010 at 5:48am Last edited: 6 September 2010 5:54am
HI,
$a = DataObject::get('DO2', "ID=1");
... returns a DataObjectSeti think you should use
$a = DataObject::get_by_id('DO2', 1);
but please provide more information regarding the DataObjects (colums, relational definitions, etc.)
-
Re: stupid question

6 September 2010 at 6:28am
hi rob.s,
Thanks, that did the trick.
Always thought that all kinds of dataobject::get returned a dataobjectset (the one a little bit more filled than the other ;-) ). -
Re: stupid question

6 September 2010 at 7:45am
DataObject::get_one('SomeDataObject', 'ID = ' . $someID), DataObject::get_by_id('SomeDataObject', $someID) returns the same single DataObject.
DataObject::get('SomeDataObject', $wherestatement); returns a DataObjectSet even if there is one DataObject that matches the $wherestatement. This means that you can use alle methods from DataObjectSet like First, Last, MoreThenOnePage, Count etc. in your php code or your template file (just the notation is little different).
Hope this explains it a little bit more.
| 690 Views | ||
|
Page:
1
|
Go to Top |



