I'm trying to extend a class used as a doctrine entity, but for some reason I keep getting the error:
There is no column with name 'location_id' on table 'admin_subdivisions'
When I say extend, I mean at the php level NOT the database level. I simply want to create another table, with an extra column. I have several entities which extend the following abstract class
abstract class LocationProxy
{
/**
* @ORM\Id
* @ORM\OneToOne(targetEntity="Location", cascade={"ALL"}, fetch="LAZY")
* @ORM\JoinColumn(name="location_id", referencedColumnName="location_id", nullable=false)
*
* @var Location
*/
protected $location;
}
None of these second level classes give me any problems. Now, I want to extend this second level class
/**
* @ORM\Entity()
* @ORM\Table(name="admin_divisions")
*/
class AdminDivision extends LocationProxy
{
}
with this
/**
* @ORM\Entity()
* @ORM\Table(name="admin_subdivisions")
*/
class AdminSubDivision extends AdminDivision
{
}
but, it produces the error. Can anybody point out what I am doing wrong?
here is the Location class definition
/**
* @ORM\Entity()
* @ORM\Table(name="locations")
*/
class Location
{
/**
* @ORM\Id
* @ORM\Column(name="location_id", type="integer", options={"unsigned"=true})
*
* @var int
*/
private $id;
}
referencedColumnName
of yourjoinColumn
is the primary key of the Location entity? – chalasrabstract Admin
class, then extending bothAdminDivision
andAdminSubDivision
from that. But I'd still like to know why the above code won't work. – Twifty$location
property. – chalasr