nima
nima

Reputation: 520

laravel have transactions status?

In codeigniter we have command trans_status() that check transaction is successful or not:

if ($this->db->trans_status() === FALSE)
{
    // error woun't be generated...
}

i want to know laravel 5.* have any like that?

Upvotes: 4

Views: 2858

Answers (1)

Bilal Ahmed
Bilal Ahmed

Reputation: 4066

Yes, you can get transaction status in laravel like this. Laravel Manual for DB::transaction

/**
 * @return boolean
 */
public function transactionalQuery()
{
    try {
        DB::transaction(function ($data) {
            // do something
        });
    } catch (\Exception $e) {
        return false;
    }

    return true;
}

Reference Code

Author Name: JarekTkaczyk

Upvotes: 11

Related Questions