Transaction with binding parameter

Hi everyone,

I’m trying to make a transaction when saving a record. The transaction works fine

when i don’t bind parameters, but as soon i bind parameters the record is not saved !!

This is my code:


$transaction=$connection->beginTransaction();

		

		try

		{

			$sql="INSERT INTO album (album_id, title_id) VALUES(:album,:title)";

			$command=$connection->createCommand($sql);

								

			$command->bindParam(":album", $album_id,PDO::PARAM_INT);

			$album_id=$album;

								

			$command->bindParam(":title", $title_id,PDO::PARAM_INT);

			$title_id=$title;

								

			$command->execute();

			

			$transaction->commit();

		}

		catch(Exception $e)

		{

   			$transaction->rollBack();

		}	




Do you have an idea why the record is not saved when using bind parameters ?

Thanks :)

First you are binding the variable $album_id, and after that you assign to it the value of variable $album ?

What is the value of $album_id at the time of calling bindParam?

The value of $album i call it in a function. But this is not the problem, the problem

is something else and i don’t know where and what. As i said, when i don’t use the transaction it’s works. And as i combine transaction and bind parameters it crash

Try adding a throw $e after $transaction->rollBack(), so if you have some exception you will see.