Skip to content

Instantly share code, notes, and snippets.

@phmLabs
Created May 26, 2014 12:53
Show Gist options
  • Save phmLabs/9c7e06e5d7854b4dc69f to your computer and use it in GitHub Desktop.
Save phmLabs/9c7e06e5d7854b4dc69f to your computer and use it in GitHub Desktop.
<?php
$event = $this->getDoctrine()
->getRepository('WeTimeboxBundle:Event')
->findBy(array("edit_id" => $eventId));
<?php
namespace PhmLabs\Bundle\WeTimeboxBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="events")
*/
class Event {
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100)
*/
protected $readonly_id;
/**
* @ORM\Column(type="string", length=100)
*/
protected $edit_id;
/**
* @ORM\Column(type="string", length=255)
*/
protected $title;
/**
* @ORM\Column(type="text")
*/
protected $description;
/**
* @ORM\Column(type="string", length=20)
*/
protected $start_date;
/**
* @ORM\Column(type="string", length=255)
*/
protected $company_logo;
/**
* @ORM\Column(type="boolean")
*/
protected $public;
/**
* @ORM\OneToMany(targetEntity="Item", mappedBy="event_id")
*/
protected $items;
}
<?php
namespace PhmLabs\Bundle\WeTimeboxBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="items")
*/
class Item {
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="integer")
*/
protected $event_id;
/**
* @ORM\Column(type="string", length=255)
*/
protected $title;
/**
* @ORM\Column(type="text")
*/
protected $description;
/**
* @ORM\Column(type="string", length=5)
*/
protected $duration;
/**
* @ORM\Column(type="integer", length=3)
*/
protected $position;
}
@digitalkaoz
Copy link

/**
 * @ORM\ManyToOne(targetEntity="Event", inversedBy="items")
 */
protected $event_id;

und Items im constructor als Collection initialisieren:

public function __construct()
{
    $this->items = new ArrayCollection();
}

und der schönheit halber noch alles private machen ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment