Thanks for your reply Matt,
The code works great, and I've adapted it slightly to suit my application.
Currently I am trying to Load up an existing bean to update its values.
Just a quick definition: plant is a machine - not a factory. I just thought I would clear this up as it could potentially affect the object relationships..
Currently i'm doing the following: I'm handing in a class object $p into the UpdatePlantObject function. This object is the one which contains all the updated data. I then load up the corresponding object from the database $plant (via $plant = R::load('plant',$p->PlantNumber); ) This is because the PlantNumber property of the $p object is the primary key of the plant in the database! Now the $plant object is loaded from the database I now wish to update its values so that they match the values of $p.
The problem I am having is that when I do this, new values are added to my costcentre, type, make & depot tables regardless if they are already existing in the table. I.e. the table is no longer showing unique values.
How do I update the related values of my $plant object without adding new (duplicated) values to the related tables?
function UpdatePlantObject($p)
{
require 'rb.php';
R::setup('mysql:host=localhost;dbname=ausgridtest',
'root','');
//make