Skip to content

Instantly share code, notes, and snippets.

@a-ast
Created April 22, 2016 08:38
Show Gist options
  • Save a-ast/cbca016aef50829e62a335f1e1cc97d2 to your computer and use it in GitHub Desktop.
Save a-ast/cbca016aef50829e62a335f1e1cc97d2 to your computer and use it in GitHub Desktop.
Doctrine merge examples
public function test_merge_listing()
{
$listingContact = new ListingContact();
$listingContact
->setId(3)
->setEmail('[email protected]')
->setMobilePhonePrefix('01578');
$listing = new Listing();
$listing
->setId(8)
->setSku('new sku')
->setDescription('Description of listing')
->setListingStart(new \DateTime())
->setListingEnd(new \DateTime("+120 days"))
->setOwnerId(1)
->setStatus('active')
->setStatusOwner('active')
->setPrice(1000)
->setShowListingAddress(false)
->setPriceNotAvailable(false)
->setTopPosition(1)
->setAddress('Listing address')
->setPetApproved(true)
->setPin(new Point([0, 0]))
->setCategory(null)
->setContact($listingContact);
$this->em->merge($listing);
$this->em->flush();
}
public function test_merge_listing_contact()
{
$listingContact = new ListingContact();
$listingContact
->setId(2)
->setEmail('[email protected]')
->setMobilePhonePrefix('01573');
$this->em->merge($listingContact);
$this->em->flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment