Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy are my Symfony/Doctrine2 entites different from my CI/D2 ones ? (Ultimately, What is the difference between Doctrine 2 and Doctrine 2 ORM ?)
    primarykey
    data
    text
    <p>I know this seems like a very basic question but PLEASE before voting down, read until the end.</p> <p>This question came to my mind when using Codeigniter along with Doctrine 2.</p> <p>I have noticed that, at least when using annotation, the synthax is slightly different than when using Doctrine 2 with Symfony2 and I am wondering why.</p> <p>I'll provide an example:</p> <p>This is a class in Symfony2 with a Many To One relation:</p> <pre><code>&lt;?php namespace Pondip\LakeBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Validator\Constraints as Assert; use Doctrine\ORM\Mapping as ORM; /** * Lake * * @ORM\Table(name="pondip_lake") * @ORM\Entity(repositoryClass="Pondip\LakeBundle\Entity\LakeRepository") */ class Lake { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var integer * @Assert\Type(type="Pondip\LakeBundle\Entity\Venue") * * @ORM\ManyToOne(targetEntity="Pondip\LakeBundle\Entity\Venue") * @ORM\JoinColumn(name="venue_id", referencedColumnName="id") */ private $venue; /** * @var string * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * @var text * * @ORM\Column(name="description", type="text", nullable=true) */ private $description; /** * @var integer * * @ORM\ManyToOne(targetEntity="Pondip\UserAccountBundle\Entity\User") * @ORM\JoinColumn(name="created_by", referencedColumnName="id", nullable=true) */ private $createdBy; </code></pre> <p>please pay attention to all the @ORM\ everywhere.</p> <p>Now, when using this with codeigniter2/Doctrine2.3.0 I have Mapping errors in my console. But, when following some tuts, I ended up removing all of the ORM\ (and the corresponding use Doctrine\ORM\Mapping as ORM) and it worked.</p> <p>This work :</p> <pre><code>&lt;?php namespace Entity; /** * Friend Model * * @Entity * @Table(name="friend") * @author Miles Yohann Merran &lt;hello_miles@hotmail.com&gt; */ class Friend { /** * @Id * @Column(type="integer", nullable=false) * @GeneratedValue(strategy="AUTO") */ protected $id; /** * @Column(type="string", length=32, unique=true, nullable=false) */ protected $name; /** * @Column(type="text", nullable=false) */ protected $description; /** * @Column(type="string", length=64, nullable=false) */ protected $picture; /** * @Column(type="string", length=64, nullable=false) */ protected $genre; /** * @ManyToOne(targetEntity="User", inversedBy="friends") * @JoinColumn(nullable=false) */ protected $user; /** * @var datetime $date * * @Column(name="date", type="datetime") */ protected $date; </code></pre> <p>When this doesn't work (pay attention at the ORM)</p> <pre><code>&lt;?php namespace Entity; use Doctrine\ORM\Mapping as ORM; /** * Friend Model * * @Entity * @Table(name="friend") * @author Miles Yohann Merran &lt;hello_miles@hotmail.com&gt; */ class Friend { /** * @Id * @Column(type="integer", nullable=false) * @GeneratedValue(strategy="AUTO") */ protected $id; /** * @Column(type="string", length=32, unique=true, nullable=false) */ protected $name; /** * @Column(type="text", nullable=false) */ protected $description; /** * @Column(type="string", length=64, nullable=false) */ protected $picture; /** * @Column(type="string", length=64, nullable=false) */ protected $genre; /** * @ORM\ManyToOne(targetEntity="User", inversedBy="friends") * @ORM\JoinColumn(nullable=false) */ protected $user; /** * @var datetime $date * * @ORM\Column(name="date", type="datetime") */ protected $date; </code></pre> <p>Why ? What is the difference ?</p> <p>EDIT: To be exact, I tried 2 entites, with the same structure, one with @ORM\ before avery annotation sentence, and one without. The one with @ORM\ wasn't managed properly by Doctrine 2 when using the terminal commands and the one without works perfectly well. I wasn't able to find any documentation about that even if I clearly see both in the doc and the src that there is Doctrine Common, Doctrine ORM and Doctrine DBAL. Aren't they compatible between each other ? how to properly manage this difference ? especially when working with another framework than S (like CI2)</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload