Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Updating field value and update

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1079 Views
  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Updating field value and update Link to this post

    Hi,

    I have code that is as follows...

    $childObject = DataObject::get_by_id($this->sourceClass, $ID);
    $childObject->myfield = $new_data;
    $childObject->write();

    and the $new data is not getting to the written back to the database.

    I have tried $childObject->forceChange(); before the write and tried $childObject->write(false,false,true); to force the write to write... I have also output the $childObject->myfield after being set and can confirm $new_data is in there...

    ...what else can I do to ensure I write this data back?

    Any help much appreciated.

    Barry

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Updating field value and update Link to this post

    Arrrrggh! This is my third thread and replied to all of them fixing them soon after raising it.

    Turns out 'myfield' in $childObject->myfield = $new_data; was spelt incorrectly and there is no failure, no report of setting a field that doesn't exist... I guess this is a great feature that I did not know about!

    Next time maybe I'll need some help from you guys!

    Barry

  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: Updating field value and update Link to this post

    No no no, self help is good! Glad you got it sorted out, I know I'd do this all the time if it wasn't for auto-complete in NetBeans.

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Updating field value and update Link to this post

    Thanks Dale, I am using Notepad++ with an FTP plugin at the moment... not the best IDE... I was (as soon as a new project starts up) start going to use PHPEclipse with code completion, goto declaration and debugging... how would that compare with NetBeans?

  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: Updating field value and update Link to this post

    They are very similar in capabilities. I prefer NetBeans because all the goodies (SVN, SQL browser, xdebug) are part of the core platform, and Eclipse always makes me install a dozen plugins to get it to a usable state.

    Both will be a great improvement over your current setup. More at http://doc.silverstripe.org/doku.php?id=tools

    1079 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.