Fuel\Core\Autoloader::add_classes(array( // Add classes you want to override here 'Fuel\\Core\\Database_Mysqli' => APPPATH.'classes/core/database/mysqli.php', 'Fuel\\Core\\Database_MySQLi_Result' => APPPATH.'classes/core/database/mysqli/result.php', 'Fuel\\Core\\Database_Transaction' => APPPATH.'classes/core/database/transaction.php', ));
$trans = Database_Transaction::instance(); $trans->start(); DB::insert('some_table')->set(array('column_name' => 'value'))->execute(); DB::insert('some_other_table')->set(array('column_name' => 'value'))->execute(); DB::insert('yet_another_table')->set(array('column_name' => 'value'))->execute(); $trans->complete(); if ($trans->status() !== true) { // Handle your errors... Debug::dump($trans->errors()); }Fuel Team, once it is robust enough, feel free to add or adapt it into the core. I namespaced the class \Fuel\Core, so if it does get added, this will make upgrading easier for those already using it. If you would prefer that I do not use the Fuel namespace for addons that I wish to contribute to Fuel core functionality, please let me know. Michael
I only "offer" it in the way that I made it work within Fuel and added it to the Github account Oil uses to install packages. It uses an existing AR (php.activerecord) which will not become Fuel's default.I have been a bit confused about the direction Database & ActiveRecord are going. I notice ActiveRecord uses DB right now, but I read some discussion on PHPActiveRecord (http://fuelphp.com/forums/posts/view_reply/212), which indicates a rewritten AR package. The package Jelmer offers uses PDO, which already has transactions built in.
The QueryBuilder will remain as is. Luke Baker's AR will probably be replaced with the package ORM we're currently writing from the ground up. The main reason for the latter is that our current AR was designed to be used by convention, while the Fuel philosophy is to work by configuration and only have convention for default values. Also there are design flaws in it when it comes to object hydration with many-many relationships.Once the direction of Database and ActiveRecord gets finalized, I plan on completing this class and sending a pull request. I would never request a merge on any code I write until I am 100% sure that is production ready.
It looks like you're new here. If you want to get involved, click one of these buttons!