Hi there,

Transaction manager example code from https://docs.phalconphp.com/3.4/en/db-models-transactions is not working if a relation is specified

Error:Value of field "robot_id" does not exist on referenced table

    $this->belongsTo(
        "robot_id",
        "Robots",
        "id",
        [
            "alias" => "Robot",
            "foreignKey" => [
                "allowNulls" => false
            ]
        ]
    );

Example code:

try {

$manager = new TxManager();
$transaction = $manager->get();
$robot = new Robots();
$robot->setTransaction($transaction);
$robot->name       = 'WALL·E';
$robot->created_at = date('Y-m-d');
if ($robot->save() === false) {
    $transaction->rollback(
        'Cannot save robot'
    );
}

$robotPart = new RobotParts();
$robotPart->setTransaction($transaction);
$robotPart->robots_id = $robot->id;
$robotPart->type      = 'head';
if ($robotPart->save() === false) {
    $transaction->rollback(
        'Cannot save robot part'
    );
}

$transaction->commit();

} catch (TxFailed $e) { echo 'Failed, reason: ', $e->getMessage(); }