3236 Posts in 942 Topics by 684 members
|Go to End|
19 March 2011 at 4:09am
I have a form where a Breeder can add a Dog to the Database. In the form there is a Dropdownfield where they can choose an other dog that would be the kid of the new dog. Like Newdog is FatherOf....
Now i've come a long way ( in my opinion) but i have no idea how to update just one field in a record.
$dogStep = $this->getSavedStepByClass('DogDetailStep');
// Create the new Dog
$dog = new Dog();
$dog->BreederID = $dog->BreederID;
// New Dog is in Database
// I need the ID of the just created Dog
$thisdog = $dog->PedigreeName;
$newDog = DataObject::get_one('Dog', "PedigreeName = '$thisdog'");
$assignkidID = $dog->FatherOfID;
//FatherOfID is a field from the form where i choose which Dog is the kid.
$kid = DataObject::get_one('Dog', "ID = '$assignkidID'");
//So now i have the kid that i choose in the form.
//Now i have to fill the field $kid->MyFatherID with $newDog->ID
And that is where i'm lost. I've tryedbut then it overwrites the whole dog with the new one, so i need to update just that one field MyFatherID.
19 March 2011 at 4:32am
I have to set the field first, and then it doesn't mather that it writes everything back, it's the same dog........duh
$kid->MyFatherID = $newDog->ID;
|Go to Top|