Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » write() updates _Live table only

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

Page: 1
Go to End
Author Topic: 1298 Views
  • netnerd85
    Avatar
    Community Member
    42 Posts

    write() updates _Live table only Link to this post

    I have a custom page type with a form, on the forms action I'm updating an object:

    $myObj = DataObject::get_by_id("myObj", $Id);
    $myObj->myProperty = 2;
    $myObj->write();

    But this only updates the _Live table and not the draft table, how can I update the draft table so it shows in the CMS?

    Thank you

  • netnerd85
    Avatar
    Community Member
    42 Posts

    Re: write() updates _Live table only Link to this post

    All I needed was to add $myObj->publish("Live", "Stage"); after the write() function.

    Thanks to this post which I found via google and not this forum search: http://www.silverstripe.org/archive/show/5780?showPost=6157&start=8

    This forum really needs a better search feature, there is lots of information but you can't get to it

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: write() updates _Live table only Link to this post

    In the development version of the forum we now have the search powered by the much more useful sphinx search engine. Initial tests show results are better but we're still lacking an 'advanced' search form. This forum will be upgraded to include this sphinx search extension before the end of the year.

    1298 Views
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.