1
を実践し、私は、この典型的なコードMySQLの取引が
$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();
}
との取引のチュートリアルと、すべてのカップルの例を見てきましたしかし、私はそれらの間にいくつかのブロックの状態を行う必要があります。 このような記述が可能ですか?
$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();
}
これは可能ですか?
はい、条件を記述できます。 –