title: How to do a PHP nested class or nested methods?
body: <p>How can I do this in PHP</p>
  
  <pre><code>$myDBClass-&gt;users()-&gt;limit(5);//output you limited users to 5
  $myDBClass-&gt;comments()-&gt;limit(3);//output you limited comments to 3
  </code></pre>
  
  <p>what I meant is nested methods or nested class (I don't know!)
  so when I call the limit method as a child of users it will know that I am calling it from  "users" method -or class- and when I call limit method -or class!- from comments It also knows that.</p>
  
  <p>what is the possible structure for a PHP class to do this thing?</p>
  
  <hr>
  
  <p>the reason for this question because I am working on my own class for database so I can easily use something like this</p>
  
  <pre><code>     $DB-&gt;comments()-&gt;id(" &gt; 3")-&gt;limit(10);
  </code></pre>
  
  <p>to generate the sql code "select * from comments where id > 3 limit 10"
  Thanks</p>