how can I solve this problem. An entity class aggregates an object. Its value should be stored in the database. I have the following entity:
<?php
class Price
{
private $_amount;
public function getAmount()
{
return $this->_amount;
}
public function setAmount($amount)
{
$this->_amount = $amount;
return $this;
}
}
/**
* Class Product
*
* @Entity
* @Table(name="product", options={"engine" = "NDBCLUSTER"})
*/
class Product
{
/**
* @Id
* @GeneratedValue
* @Column(name="id", type="integer")
* @var int
*/
private $_id;
/**
* @Column(name="price", type="decimal", precision=10, scale=2)
* @var Price
*/
private $_price;
}
?>
If I want to store a price in the database, how can I do that? This is obviously not working:
<?php
$price = new Price();
$price->setAmount(19.99);
$product = new Product();
$product->setPrice($price);
$em->persist($product);
$em->flush();
?>
Do I have to implement a new mapping type?