Welcome Guest, Not a member yet? Register   Sign In
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




Theme © iAndrew 2016 - Forum software by © MyBB