I'm using Doctrine ORM 2. I got the following entity class.
/**
* @Entity
* @Table(name="objects")
*/
class MyObject
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
private $id;
/**
* @var Coordinate
*/
private $coordinate;
}
class Coordinate
{
private $x;
private $y;
private $z;
}
I want to implement the 3 coordinate values in a separate class for better handling within php. But within the database I want the 3 values to be included in the database table "objects".
Does anyone know how to achieve this?
Best regards
Edit: I found a workaround but it's not the nicest.
/**
*
* @var integer
* @Column(type="integer")
*/
private $x;
/**
*
* @var integer
* @Column(type="integer")
*/
private $y;
/**
*
* @var integer
* @Column(type="integer")
*/
private $z;
public function getCoordinate()
{
return new Coordinate($this->x, $this->y, $this->z);
}
public function setCoordinate(Coordinate $coord)
{
$this->x = $coord->getX();
$this->y = $coord->getY();
$this->z = $coord->getZ();
}