Skip to content

Instantly share code, notes, and snippets.

@gpfiel
Created November 21, 2013 15:53
Show Gist options
  • Save gpfiel/7584160 to your computer and use it in GitHub Desktop.
Save gpfiel/7584160 to your computer and use it in GitHub Desktop.
Create photo to album
<?php
$album = new Album;
$photo = new Photo;
if(isset($_POST['id']))
$album = $this->getEntityManager()->getRepository('Admin\Entity\Album')->find($this -> params() -> fromPost('id'));
$photo -> setDate(date_create($_POST['date_photo']));
$photo -> setDescription($_POST['description_photo']);
$photo -> setMainPhoto($novo_nome);
$album -> assignedToPhoto($photo);
if(!isset($_POST['id']))
{
$album -> setTitle("Album incompleto.");
$album -> setStatus(2);
}
$em = $this->getEntityManager();
$em -> persist($album);
$em -> persist($photo);
$em -> flush();
$id_album = (isset($_POST['id']) ? $_POST['id'] : $album -> getId());
$id_photo = $photo -> getId();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment