I am creating two related models with transactions.
When I use normal transactions everything goes fine. When I use isolated transactions I am getting an error...
This code (normal) works ok:
public function test2Action() {
$this->db->begin();
$user = new Users();
$user->setType(Users::COMPUTER);
$user->create();
$userName = new Names();
$userName->setName("Andrej");
$user->names = $userName;
$user->update();
$this->db->commit();
}
This code (isolated) does not work:
public function testAction() {
$manager = $this->transactions;
$transaction = $manager->get();
$user = new Users();
$user->setTransaction($transaction);
$user->setType(Users::COMPUTER);
$user->create();
$userName = new Names();
$userName->setTransaction($transaction);
$userName->setName("Andrej");
$user->names = $userName;
var_dump($user->update()); //returns false
var_dump($user->getMessages()); //errors here
}
Error I get:
array (size=1)
0 =>
object(Phalcon\Mvc\Model\Message)[89]
protected '_type' => string 'InvalidUpdateAttempt' (length=20)
protected '_message' => string 'Record cannot be updated because it does not exist' (length=50)
protected '_field' => null
protected '_model' => null
protected '_code' => int 0
Is this a bug or am I doing sth wrong?
Another question, assuming both methods work, what is the difference "inside"? Security, consistency, performance?
TIA!