title: How do you make to work the database transaction in my code in Zend 2?
body: <p>This is my code from my model :</p>
  
  <pre><code>namespace Application\Model;
  
  use Zend\Db\Adapter\Adapter;
  use Zend\Db\TableGateway\AbstractTableGateway;
  
  class UsersTable extends AbstractTableGateway {
  
      public function __construct(Adapter $adapter) {
          $this-&gt;adapter = $adapter;
      }
  
      public function fetchAll() {
  
          $results = $this-&gt;adapter-&gt;query("SELECT * FROM users");
          $results = $results-&gt;execute();
          return $results-&gt;current();
  
      }
      public function insertNewUser($new_user_data){
          $ip = $_SERVER['REMOTE_ADDR'];
          try {
              $x = $this-&gt;adapter-&gt;getDriver()-&gt;getConnection()-&gt;beginTransaction();
              var_dump($x);
  
              $insert =   $this-&gt;adapter-&gt;query("INSERT INTO users (username,`name`,email,`password`, birthday,country,city,address,website,img_url,`date`,`update`,ip,email_confirm,`status`) values ('".$new_user_data['username']."','".$new_user_data['name']."','".$new_user_data['mail']."','".md5($new_user_data['password'])."','".$new_user_data['birthday']."','".$new_user_data['country']."','".$new_user_data['city']."','".$new_user_data['address']."','".$new_user_data['website']."','".$new_user_data['user_picture']."',NOW(),
                  NOW(),'".$ip."','0','normal')");
              $insert-&gt;execute();
  
              $x = $this-&gt;adapter-&gt;getDriver()-&gt;getConnection()-&gt;commit();
  
          } catch (Exception $e) {
              $this-&gt;adapter-&gt;getDriver()-&gt;getConnection()-&gt;rollback();
              echo "Failed: " . $e-&gt;getMessage(); 
          }
  
      }
  
  }
  </code></pre>
  
  <p>The insert query it works fine and it is executed. BUT the result of the var_dump($x) it is null. WHY ? and how do i test it to make sure that it works ? becuase i got no error or warnings.</p>