Hope it's not too late to shed some light on this matter. You are mixing two concepts - 1. lazy loading (in this case lazy connecting), and 2. persistent connection.
The posted code correctly establishes an actual database connection ONLY when a query is made. The correctness of the code hinges on how the code is used. Consider the following pseudo calls:
- instantiate the Database class, which invokes the constructor
- explicitly call the connect function
- make a query
The above sequence nullifies the benefit of the lazy connection because a connection is made regardless. If Step 2 is removed, however, the query function will call connect, which will then create a real connection to the database.
Why is this useful? In a complex project, the connection handler is often included in some header file. Database queries are made in various components. By the time a query is made, the database connection has to be ready. As a result, a connection is created even on pages that don't load anything from the database. Keep in mind that TCP connections are valuable server resources. Establishing too many unused connections is just wasteful. A lazy connecting method addresses exactly this issue.
Persistent connection is a different concept. It means that at the end of a page session the connection is not closed. When a new connection is needed, PHP looks for an "identical" connection to reuse.
For the sake of completeness, I'd like to point out that persistent connection is also not the same as connection pooling, though a persistent connection can be viewed as a connection pool of 1.