21294 Posts in 5734 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » DataObject::get_one() fails even if the object exists & matches criteria
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 837 Views |
-
DataObject::get_one() fails even if the object exists & matches criteria

2 September 2010 at 9:29pm Last edited: 2 September 2010 9:32pm
Is that even possible? I have the following code, but it's failing at the if statement. I did a print_r($p) to find out what it was outputting, and all it was giving up was a "1". Hmm???? And yes, I checked the database to make sure everything existed.
BTW, the class Profile is an extension of Page.
public function EditProfileLink() {
$mid = Member::currentUserID();
if($p = DataObject::get_one("Profile", "MemberID = $mid")) {
return $p->Link('edit');
} else
return false;
} -
Re: DataObject::get_one() fails even if the object exists & matches criteria

4 September 2010 at 8:46pm
So if you do a Debug::show(DataObject::get_one("Profile", "MemberID = $mid")); does it return 1 still or just the object? How about Debug::show(DataObject::get_one("Profile"));
| 837 Views | ||
|
Page:
1
|
Go to Top |


