I'm trying to update my app to phalcon 4, but it seems that we're no longer able to update values of relations. Even if I just print the value, it's reseted. The only way seemts to create new objects and clone the data to handle updates of relations.
Is there a way to handle this without recreation my models?
i also created a simple example via phalcon devtools to show you my problem:
class IndexController extends ControllerBase
{
public function indexAction()
{
$product = Product::findFirst();
$product->price->amount = 1337;
// this will print 100 ?!?? (100 is the value of the database)
echo $product->price->amount;
exit;
}
}
Here are my models:
namespace marvas;
class Product extends \Phalcon\Mvc\Model
{
public $productId;
public $priceId;
public $name;
public function initialize()
{
$this->setSchema("test");
$this->setSource("product");
$this->belongsTo('priceId', 'marvas\Price', 'priceId', ['alias' => 'Price']);
}
}
-
namespace marvas;
class Price extends \Phalcon\Mvc\Model
{
public $priceId;
public $amount;
public function initialize()
{
$this->setSchema("test");
$this->setSource("price");
$this->hasOne('priceId', 'marvas\Product', 'priceId', ['alias' => 'Product']);
}
}