I created two Doctirne entities , which has many to many relationship together in between them. But when i trying to created the db tables from that schema , i am getting a weird exception which is a SchemaException saying "Table with somename already exists" but as i double checked the database , it does not contain any tables at all. Please guide me to resolve this issue. Thanks
Entity Doctor
<?php
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="doctors")
*/
class Default_Model_Doctor
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/** @Column(type="string") */
private $name;
/**
* @ManyToMany(targetEntity="Default_Model_Patient", inversedBy="doctors")
* @JoinTable(name="doctors_patients",
* joinColumns={@JoinColumn(name="doctor_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="patient_id", referencedColumnName="id")}
* )
*/
private $patients;
public function __construct()
{
$this->patients = new ArrayCollection();
}
public function setName($string) {
$this->name = $string;
return true;
}
public function getName() {
return $this->name;
}
}
Entity Patient
<?php
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="doctors")
*/
class Default_Model_Patient
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/** @Column(type="string") */
private $name;
/**
* @ManyToMany(targetEntity="Default_Model_Doctor", mappedBy="patients")
*/
private $doctors;
public function __construct()
{
$this->doctors = new ArrayCollection();
}
public function setName($string) {
$this->name = $string;
return true;
}
public function getName() {
return $this->name;
}
}
This is the error i receive from Doctrine cli tool when creating the Schema.
Please follow this link for the screenshot i have attached which shows the error clearly.
Change @Table(name="doctors") in your Patients model to @Table(name="patients")