title: Zend Framework 2 instantiate table in Model
body: <p>I have a Model, called Admin with custom functions.</p>
  
  <pre><code>&lt;?php
  
  namespace ZendCustom\Model;
  
  use Zend\Db\TableGateway\TableGateway;
  use Zend\Db\Exception\ErrorException;
  
  abstract class Admin {
  
  /**
   * @var TableGateway
   */
  protected $_table;
  
  /**
   * @var array 
   */
  protected $data;
  
  /**
   * @var bool
   */
  protected $loaded = false;
  
  /**
   * Constructor
   * 
   * @param array $data
   * @throws Exception
   */
  public function __construct(array $data = array()) {
      if (!is_null($this-&gt;_table)) {
          if (!empty($data)) {
              $this-&gt;loaded = !empty($this-&gt;data);
          }
      } else {
          die('Please, specify table for ' . __CLASS__);
      }
  }
  }
  </code></pre>
  
  <p>And docs says to describe table, we should use:</p>
  
  <pre><code>// module/Album/src/Album/Controller/AlbumController.php:
      public function getAlbumTable()
      {
          if (!$this-&gt;albumTable) {
              $sm = $this-&gt;getServiceLocator();
              $this-&gt;albumTable = $sm-&gt;get('Album\Model\AlbumTable');
          }
          return $this-&gt;albumTable;
      }
  </code></pre>
  
  <p><a href="http://framework.zend.com/manual/2.0/en/user-guide/database-and-models.html" rel="nofollow">http://framework.zend.com/manual/2.0/en/user-guide/database-and-models.html</a></p>
  
  <p>How could I set my Model Table inside Admin Model, without Controller?</p>