Jump to:

3459 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » write function result to dataobject

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 185 Views
  • voodoochile
    Community Member
    52 Posts

    write function result to dataobject Link to this post

    Hi There

    I am a little stuck at the moment, I have a function (this works ok) that looks like this.

    function Addab()
    $a = 1
    $b = 2
    $c = $a+$b;
    return $c;

    my question is how can i get the result and write it to a field in another dataobject?

    any help or ideas would be appereciated thank you

  • Willr
    Forum Moderator
    5497 Posts

    Re: write function result to dataobject Link to this post

    How you get the result of that depends on where that function is and where you want to write the dataobject?

    To update a dataobject it's a simple task of getting the object, setting the property and calling write()

    $obj = Page::get()->first();
    $obj->Title = "Test";

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.