In virtually all cases in PHP†, you don't need to close the connection after each query.
If you read a book, do you close the book after you read each sentence? No, you keep the book open until you're finished reading. There's nothing to be gained by closing and reopening the book, and it just slows you down.
Closing a database connection has nothing to do with preventing SQL injection. That sounds like either you have misunderstood the advice, or else the advice was given by someone who doesn't understand SQL injection.
† There are some other languages like Java or Go that use connection pools, so a small number of connections can be shared by many threads. There's an advantage to "closing" a connection, which is really just returning the connection to the pool for another thread to use. But this doesn't apply to PHP, which AFAIK has no support for connection pools, and most PHP applications aren't written as multi-threaded code.