Welcome Guest, Not a member yet? Register   Sign In
How does $this->db->trans_status() work?
#1

[eluser]Syed Rakib Al Hasan[/eluser]
How exactly does `$this->db->trans_status()` understand that whether the queries in the transaction were successful or not?

Source: http://ellislab.com/codeigniter/user-gui...tions.html
Quote:
Code:
$this->db->trans_begin();

$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');

if ($this->db->trans_status() === FALSE){
    $this->db->trans_rollback();
}
else{
    $this->db->trans_commit();
}
#2

[eluser]WanWizard[/eluser]
It's status is set to FALSE if a query fails, so if running a query returns FALSE.
#3

[eluser]Syed Rakib Al Hasan[/eluser]
[quote author="WanWizard" date="1341261683"]It's status is set to FALSE if a query fails, so if running a query returns FALSE.[/quote]
Thanks. I am interested to know HOW does dba->get_status() understand that it, in fact, is returning the correct status of the SQL? Is it based on SQL deadlock issues? Is it based on malformed SQL strings? Is it based on timeout issues? I actually have about 10 to 15 SQLs between a trans_start and trans_complete
#4

[eluser]WanWizard[/eluser]
It's based on the return value of whatever function is used to run the query (which depends on the driver used).
So basically on any error that causes the query not to complete succesfully.




Theme © iAndrew 2016 - Forum software by © MyBB