Skip to content

Instantly share code, notes, and snippets.

@gzankevich
Created August 8, 2012 14:54
Show Gist options
  • Save gzankevich/3295625 to your computer and use it in GitHub Desktop.
Save gzankevich/3295625 to your computer and use it in GitHub Desktop.
$em = $this->getEntityManager();
$viewing = new Viewing();
$viewing->setMeetingPerson('t');
$viewing->setMeetingPlace('t');
$viewing->setContactNumber('1');
$viewing->setViewingAt(new \DateTime());
$lmo = new LeadMatchingOffice();
$lmo->addViewing($viewing);
$lmo->setDistanceMiles(1);
$viewing->setLeadMatchingOffice($lmo);
$em->persist($lmo);
$em->flush();
$em->remove($lmo);
$em->flush();
Phoenix\CRMBundle\Entity\LeadMatchingOffice:
type: entity
table: lead_matching_office
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
...
oneToMany:
viewings:
targetEntity: Phoenix\CRMBundle\Entity\Viewing
mappedBy: lead_matching_office
cascade: [persist, delete]
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`phoenix`.`viewing`, CONSTRAINT `FK_F5BB46989B12193B` FOREIGN KEY (`lead_matching_office_id`) REFERENCES `lead_matching_office` (`id`))
Phoenix\CRMBundle\Entity\Viewing:
type: entity
table: viewing
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
...
manyToOne:
lead_matching_office:
targetEntity: Phoenix\CRMBundle\Entity\LeadMatchingOffice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment