Skip to content

Instantly share code, notes, and snippets.

@agussudarmanto
Last active March 31, 2018 23:56
Show Gist options
  • Save agussudarmanto/9307f6e9735d4be4d5026ff8440d8afa to your computer and use it in GitHub Desktop.
Save agussudarmanto/9307f6e9735d4be4d5026ff8440d8afa to your computer and use it in GitHub Desktop.
All Codeigniter

All Codeigniter scripts

Transaction

// controller code
$this->db->trans_start();
$this->maincategory_model->first_function($maincategoryData);
$this->market_model->second_function($marketData); 
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
    throw error
        `enter code here`
} 

// Maincategory_model code
public function first_function($maincategoryData)
{
    return $this->db->insert_batch('maincategory_users_mapping', $maincategoryData);
}

// Market_model code
public function second_function($marketData)
{
    return $this->db->insert_batch('market_users_mapping', $marketData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment