CodeIgniter Forums

Full Version: maybe transaction bug !
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Nima A.[/eluser]
well, I'm not sure about it, but let's try , ...
consider a situation which you have 3 queries in a transaction (apperently in a model), as described below :


Code:
....
$this->db->trans_start();

//query1 : right query
$query1 = "update ....";
$lnk1 = $this->db->query($query1);

//query2 : wrong query , cause error , the operation will stop here
$query2 = "update ....";
$lnk2 = $this->db->query($query2);


//query3 : right query - never executes in this situation
$query3 = "update ....";
$lnk3 = $this->db->query($query3);


$this->db->trans_complete();

in this situation, everything is fine ! first, query1 executes successfully and the result affects database fields, but query2 generates sql error and thus, roll back operation starts automatically for query1 and finally query1 does not affect DataBase (this is correct and that's what we expect)

everything is fine till now, but from now on ...

>> delete the contents of query1 and query2 to let your model method contain just query3 , I mean this :

Code:
$this->db->trans_start();
//query3 : right query
$query3 = "update ....";
$lnk3 = $this->db->query($query3);


$this->db->trans_complete();

and then refresh the previous page that described the error
in this case we expect to see the result of query3 (just query3 !) but unfortunately previous query1 also affect the database !!!

why ?

El Forum

[eluser]Nima A.[/eluser]
any opinions ?
"given enough eyeballs , are bugs are shallow " Wink

El Forum

[eluser]Nima A.[/eluser]
is there anybody out there ?
anyone check the code ?

yesterday , I was reading an article named : Notes on Choosing a PHP Framework: A Quick Comparison of CodeIgniter and Kohana (you can find it here : http://thislab.com/2008/02/23/notes-on-c...nd-kohana/)

and I found this :

Quote:Some of the users on the CI forum got frustrated because their bug reports and feature requests were ignored. As a result of that, BlueFlame was born, and later renamed to Kohana.

is that true ? if so, I'm so sorry about that, a professional framework such as CI that rises in open source culture, with it's greate community do not take attentions to bug reports !

and once more, I should mention that I'm not sure that It's a bug, so I would appreciate if someone test the code above,

with the best wishes for CI community

El Forum

[eluser]Henrik Pejer[/eluser]
Can you verify that this is a CI-bug and not a DB-bug? CI does not implement an internal transaction library or function: it simply uses the transaction capabilities of the database you are using. This means that CI does not analyze your queries and if something goes wrong, tries to restore the affected rows to its previous state.

If you want to double check: recreate the code without using CI, and see what happens.

Good luck!