title: Zend Framework: How to write a correct model that use another table?
body: <p>I have models in project that use more than one table to select.</p>
  
  <p>How can I write code like this more correct?</p>
  
  <blockquote>
    <p>public function __construct()
       {</p>
  
  <pre><code>   $this-&gt;_name = DB_PREFIX . 'teachers';
     parent::__construct();
  </code></pre>
    
    <p>}</p>
    
    <p>public function init()
      {</p>
  
  <pre><code>  $this-&gt;db = Zend_Db_Table::getDefaultAdapter();
  </code></pre>
    
    <p>}</p>
    
    <p>public function getTeachers($course_id)
      {</p>
  
  <pre><code>  $students_query = $this -&gt;db-&gt;select()
                            -&gt;from($this-&gt;_name, '')
                            -&gt;from(&lt;ANOTHER_TABLE_NAME&gt;, array('uid', 'ulogin'))
                            -&gt;where("&lt;ANOTHER_TABLE_NAME&gt;.uid = {$this-&gt;_name}.teacher_id")
                            -&gt;where("{$this-&gt;_name}.course_id = ?", $course_id)
                             -&gt;order("&lt;ANOTHER_TABLE_NAME&gt;.ulogin");
  
    $result = $this-&gt;db-&gt;fetchAll($students_query) ? $this-&gt;db-&gt;fetchAll($students_query) : NULL;
  
    return $result;
  </code></pre>
    
    <p>}</p>
  </blockquote>