<?php
$entity = new MyEntity();
$entity->setAttr('some attr');
$em->persist($entity);
$em->flush();
?>
<?php
class MyEntity {
/*** Other code here ***/
public function addPoint($point) {
$total_points = $this->getAvgPoints() * $this->getReviewsnum();
$new_reviewsnum = $this->getReviewsnum() + 1;
$new_points = ($total_points + $point) / $new_reviewsnum;
$this->setReviewsnum($new_reviewsnum);
$this->setAvgPoints($new_points);
$parent = $this->getParent();
if ($parent)
$parent->addPoint($point);
}
}
?>