|
|
| |
1. Transactions doesn't work correctly |
|
Reply |
|
|
 Marco Rossi | 2013-01-21 15:52:05 |
Hi!!!
I'm trying to make a rollback after a query, but doesn't work...
if i execute this
$db_pdo->transaction("B");
for($i=0;$i<20000;$i++){
$db_pdo->query("INSERT INTO test_insert (name) VALUES ('Gino');");
}
$db_pdo->transaction("R");
it commits the query without rollback...
How can i fix it? |
| |
2. Re: Transactions doesn't work correctly |
|
Reply |
|
|
 Marco Rossi | 2013-01-21 16:47:35 - In reply to message 1 from Marco Rossi |
i made this modify in the class:
($this->con->query("SET ISOLATION TO SERIALIZABLE");)
public function transaction($type){
$this->err_msg = "";
if($this->con!=null){
try{
if($type=="B"){
$this->con->query("SET ISOLATION TO SERIALIZABLE");
$this->con->beginTransaction();
}
elseif($type=="C")
$this->con->commit();
elseif($type=="R")
$this->con->rollBack();
else{
$this->err_msg = "Error: The passed param is wrong! just allow [B=begin, C=commit or R=rollback]";
return false;
}
}catch(PDOException $e){
$this->err_msg = "Error: ". $e->getMessage();
return false;
}
}else{
$this->err_msg = "Error: Connection to database lost.";
return false;
}
}
|
|