that is call method chaining. If the methods Query, Where, and extra (and whichever other method that needs chaining) you just need to return the current instance of the class that $do is an instance of. for example, at the end of the Query method just put, return $this;
I would have done the same as Tony.
A class with methods "Query", "Where", "Limit", etc... + a property "Results" pointing on a private collection storing the results of the query.
The method "Query" puts the results of the query in the private collection and then, the methods "Where" and "Limit" make the limitations in the collection.
The bad thing in that is that it can returns a lot of unnecessary data but for the case you don't want to apply a "where" clause after the "Query", it's ok.
Even if you can get this working it is a bad idea, SQL is SQL and PHP is PHP; dont mix them. There is no valid reason to be defining parts of your query like that, it can create bugs and severely limits your ability to write clean queries queries if they are to get complex. The default MySQL library for PHP is bad enough as is, dont make it worse.