title: How to get subtree table in php
body: <p>I have a table like this :</p>
  
  <pre><code>id    title      parent_id
  1       A           0
  2       B           0
  3       C           1
  4       F           3
  5       O           3
  6       D           2
  7       J           6
  8       T           2
  9       P           8
  
  
  A
     C
        F
        O
  
  B
    D
      J
    T
      P
  </code></pre>
  
  <p>now, if I give 2, this function should return:</p>
  
  <pre><code>6
  8
  7
  9
  </code></pre>
  
  <p>and also if I give 3 it function should return:</p>
  
  <pre><code>4
  5 
  </code></pre>
  
  <ul>
  <li>I don't want just leaf nodes !!!</li>
  <li>I think there is a sql query.</li>
  </ul>