Ich habe ein paar Beispiele für Transaktions Tutorial und alle mit diesem typischen Code gesehenMysql Transaktionen praktiziert
$this->db->trans_begin();
$this->db->query('WRITE TO TABLE A');
$this->db->query('WRITE TO TABLE B');
$this->db->query('WRITE TO TABLE c');
$this->db->query('WRITE TO TABLE D');
$this->db->query('WRITE TO TABLE E');
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
}
else
{
$this->db->trans_commit();
}
Aber ich brauche zwischen ihnen etwas Block Zustand zu tun. Ist es möglich so etwas zu schreiben?
$this->db->trans_begin();
$this->db->query('WRITE TO TABLE A');
if(some_condition){
$this->db->query('WRITE TO TABLE B');
}
$this->db->query('WRITE TO TABLE c');
if(some_other_condition){
//Do some operations or calculations here and then write to database
$this->db->query('WRITE TO TABLE D');
}
$this->db->query('WRITE TO TABLE E');
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_rollback();
}
else
{
$this->db->trans_commit();
}
Ist das möglich?
Ja, Sie können eine Bedingung schreiben. –