Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace OdooOfficeHelper;
- use MagentoFrameworkAppResourceConnection;
- /**
- *
- */
- class DbConnection
- {
- /**
- * Define common connection
- * @var unknown
- */
- protected $_resource;
- protected $_dbConnection;
- protected function __construct(
- ResourceConnection $resource,
- )
- {
- # code...
- // Set common connection
- $this->_resource = $resource;
- $this->_dbConnection = $this->_resource->getConnection();
- }
- public function Trans(){
- try{
- // Start transaction
- $this->_dbConnection->beginTransaction();
- //........
- // Commit transaction
- $this->_dbConnection->commit();
- } catch (Exception $e) {
- // Rollback transaction
- $this->_dbConnection->rollBack();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement