Simple DB API for inserting a record
When you are using a class you can utilize a private/protected class property. As said you know about PDO and since I am not very familiar with the old school sqlsrv_* functions I have used PDO in the examples. An example could be.

class Database {

    /*
     * Having a private/protected property ensures that only
     * the class itself can change/removed the connection. This way calling
     * code cannot mess something up regarding the connection.
     */
    private $pdo;

    public function __construct($dsn, $username, $password, array $options)
    {
        $this-&gt;pdo = new PDO($dsn, $username, $password, $options);
    }

    public function __destruct()
    {
        $this-&gt;close();
    }

    /**
     * This is an utility method to expose the PDO instance. This
     * enables calling code to use the full toolset of PDO.
     *
     * @return PDO
     */
    public function pdo()
    {
        return $this-&gt;pdo;
    }

    public function query($sql) 
    {
        /*
         * I do not enclose this inside a try-catch block
         * as only the calling code can decide if the application
         * can recover from the exception state.
         */
        return $this-&gt;pdo-&gt;query($sql);
    }

    public function close()
    {
        /*
         * Since PDO is an object closing a connection
         * is done by assigning the value NULL.
         */
        $this-&gt;pdo = null;
    }

}


If you look at the Database::close() method you can see that no parameters are required. We already have the property storing the current connection available. I am also using a __destruct() method to ensure the connection is closed as soon as the object loses all references. This frees up server resources earlier than if the connection was closed when the script ended.

You can also store the connection details/credentials inside the class an lazy load the connection only when it is actually required. There are plenty of tutorials around the web about this.

Hope this can help, happy coding!