We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

query / find in a transaction?

Hi!

Is it possible to make a query inside a transaction?

Let's say I am adding 100 records inside one transaction. Before adding each record I need to check if a simmiliar one have already been added within the ongoing transaction.

TIA!

Edit:

I would like to use it this way:


$transaction = $manager->get();

//adding records ...

$car = new Car();
$car->setTransaction($transaction);
$car->setPlate('XYZ');
$car->create();

// adding more records ...

//I want to check here if a car with plates XYZ have been added during transaction already

Car::findByPlate('XYZ'); //PROBLEM! this returns "false" and I want it to return "true"

$manager->commit(); //from here the car will be visible in DB

Car::findByPlate('XYZ'); //returns "true"

I am using MySQL.