Running Transactions Manually in PostgreSQL

#1
[eluser]Lima[/eluser]
As we look at manual, running transactions manually :

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();
}

My code look like this

Code:
$sql  = "BEGIN;";
$sql .= "AN SQL QUERY...;";
$sql .= "ANOTHER QUERY...;";
$sql .= "AND YET ANOTHER QUERY...;";
$sql .= "END;";

$this->db->query($sql);

My question is, is my code right things to do?

Thanks


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.