Hi
I am cracking my head and studying the examples and forums but just couldn’t get the following to work.
I have 2 tables (main and sub). Main has one-to-many relationship to Sub. So, Main can have many Sub.
I want to create a new Sub and add it to Main. Just couldn’t do it.
Here are my codes:
class Job_group_main {
private $job_description;
private $subgroup;
private $objectId;
public function getDescription() {
return $this->job_description;
}
public function setDescription( $job_description ) {
$this->job_description = $job_description;
}
public function getobjectId() {
return $this->objectId;
}
public function setobjectId( $objectId ) {
$this->objectId = $objectId;
}
public function getSubgroup() {
return $this->subgroup;
}
public function setSubgroup( $subgroup ) {
$this->subgroup = $subgroup;
}
}
class Job_group_sub {
private $job_description;
private $jobdescriptions;
private $objectId;
private $ownerId;
public function getDescription() {
return $this->job_description;
}
public function setDescription( $job_description ) {
$this->job_description = $job_description;
}
public function getObjectId() {
return $this->objectId;
}
public function setObjectId( $ownerId ) {
$this->ownerId = $ownerId;
}
public function getOwnerId() {
return $this->ownerId;
}
public function setOwnerId( $objectId ) {
$this->objectId = $objectId;
}
/*
public function getSubgroup() {
return $this->subgroup;
}
public function setSubgroup( $subgroup ) {
$this->subgroup = $subgroup;
}
*/
}
class Job_group_sub {
private $job_description;
private $jobdescriptions;
private $objectId;
public function getDescription() {
return $this->job_description;
}
public function setDescription( $job_description ) {
$this->job_description = $job_description;
}
public function getObjectId() {
return $this->objectId;
}
public function setObjectId( $ownerId ) {
$this->ownerId = $ownerId;
}
}
$jsc = new Job_group_sub();
$jsc->setDescription( "ABC" );
$jmc = Backendless::$Persistence->of( 'Job_group_main')->findById( $jmc_objectId,2 );
$subgroups = $jmc->getSubgroup();
$subgroups[] = $jsc;
$jmc->setContacts($subgroups);
$saved_jmc = Backendless::$Persistence->of("Job_group_main")->save( $jmc );
HELP!!