Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

write() updates _Live table only


Reply


3 Posts   1455 Views

Avatar
netnerd85

Community Member, 42 Posts

2 September 2010 at 3:45pm

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

Avatar
netnerd85

Community Member, 42 Posts

2 September 2010 at 4:35pm

Edited: 02/09/2010 4:35pm

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 :(

Avatar
Willr

Forum Moderator, 5513 Posts

2 September 2010 at 7:22pm

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.