title: FETCH_ASSOC SHOW ONLY 1 DATA AND LOOP INFINITE PHP
body: <p>I currently working in getting the list of church in my project which have 3 data but the problem is that when I try to loop in <code>while</code> it loop infinite then when a <code>var_dump</code> only 1 data showed. But when I use <code>PDO</code> it works properly.</p>
  
  <p><strong>here is my DATABASE class</strong></p>
  
  <pre><code>&lt;?php
  namespace classes\worker;
  
  use \mysqli;
  
  const DB_HOST = 'localhost';
  const DB_USERNAME = 'root';
  const DB_PASSWORD = '';
  const DB_NAME = 'db_sk';
  
  class Database {
      public function __construct() {
          $this-&gt;db = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
  
          if($this-&gt;db-&gt;connect_error) {
              die($this-&gt;db-&gt;connect_error);
          }
      }
  
      protected function select($table, $condition = '', $column = '*') {
          $condition = ($condition == '') ? '' : ' WHERE ' . $condtion;
  
          $query = 'SELECT ' . $column . ' FROM ' . $table . $condition . ';';
  
          $sth = $this-&gt;db
                      -&gt;query($query);
  
          if($sth) {
              return $sth;
          } else {
              return $this-&gt;db
                          -&gt;error;
          }
      }
  
      protected function insert($table, array $data) {
          ksort($data);
  
          $column = join(', ', array_keys($data));
          $values = '"' . join('", "', array_values($data)) . '"';
  
          $query = 'INSERT INTO ' . $table . '(' . $column . ') VALUES(' . $values . ');';
  
          $sth = $this-&gt;db
                      -&gt;query($query);
  
          if($sth) {
              return $this-&gt;db
                          -&gt;insert_id;
          } else {
              return $this-&gt;db
                          -&gt;error;
          }
      }
  
      protected function update($table, array $data, $condition) {
          ksort($data);
  
          $set = '';
  
          foreach($data as $keys =&gt; $values) {
              $set .= $keys . '="' . $values . '", ';
          }
  
          $set = rtrim($set, ', ');
  
          $query = 'UPDATE ' . $table . ' SET ' . $set . ' WHERE ' . $condition . ';';
  
          $sth = $this-&gt;db
                      -&gt;query($query);
  
          if($sth) { return true; } else { return false; }
      }
  
      protected function delete($table, $condition) {
          $query = 'DELETE FROM ' . $table . ' WHERE ' . $condition . ';';
  
          $sth = $this-&gt;db
                      -&gt;query($query);
  
          if($sth) { return true; } else { return false; }
      }
  }
  </code></pre>
  
  <p><strong>here is my Church class</strong></p>
  
  <pre><code>&lt;?php
  namespace classes\helper;
  
  use \classes\worker\{Database};
  
  final class Church extends Database {
      public function getChurch() : object {
          return $this-&gt;select('tbl_church_info', '', 'acc_id, name');
      }
  }
  </code></pre>
  
  <p><strong>and here is the page where I test the result:</strong></p>
  
  <pre><code>&lt;?php 
      use \classes\helper\{Church}; 
  
      $church = (new Church())-&gt;getChurch();
  
      var_dump($church); // only show 1 data but has 3 data in database
  
      while(($row = $church-&gt;fetch_assoc()) !== NULL) {
         echo $row['acc_id']; 
      } // which loop infinite
  
  ?&gt;
  </code></pre>