fuel / docs

Fuel PHP Framework - Fuel v1.x documentation
http://fuelphp.com/docs
Other
168 stars 234 forks source link

Explained example on how to use DB transtactions #271

Closed billmn closed 12 years ago

billmn commented 12 years ago

In DB Class, transactions methods doesn't explains well how to use it

http://docs.fuelphp.com/classes/database/db.html#/method_start_transaction

I think it might be enough some explained examples

WanWizard commented 12 years ago

I would assume that people that want to use transactions know what they are and how they work?

Do you have anything in mind? Can you suggest and example (probably one that contains both start, commit and rollback)?

billmn commented 12 years ago

Absolutely ... who uses transactions must know what they are and how they work.

I thought that a more complete example could better explain how to use the methods of the transactions together ... I was thinking something like:

try
{
    DB::start_transaction();

    // some query ...

    DB::commit_transaction();

    // return query result
}
catch (Exception $e)
{
    // rollback pending transactional queries
    DB::rollback_transaction();

    throw $e;
}

What do you think? Have you a better example?