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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

ID of an entry in the DB before write()?

Go to End

2 Posts   2460 Views


Community Member, 17 Posts

22 February 2009 at 10:54am

Edited: 22/02/2009 10:54am

Aaand, me again :)

This time I want to store a reference to the entry that I'm going to write.
For testing I whipped up some code that tries to store the ID of the entry simply in an extra field, something like this:

function saveCalEntry($data, $form) {
$entry = new simpleCalEntry();
$IDofthisdata = $entry->ID; // How do I get the ID of this new entry?
$entry->recurring = $IDofthisdata;

But unfortunately it seems that ID isn't set before write(). Any ideas on how I could go for it?

Thanks in advance /Carsten


Community Member, 17 Posts

22 February 2009 at 12:13pm

Answering myself again, got the hint from ajshort:
No, you can't easily get the ID of an entry before write() but you can get it immediately afterwards then fiddle what you want and call write() again.
Easy, huh? ;)