On Friday, 18 October 2019 at 06:22:33 UTC, Vino wrote:
Hi All,

Request your help in converting a PHP code to D equivalent code


You can get one connection object and close it :)

```D

import hunt.database;

class AvmTest {

    private Database _db;

    this() {
_db = new Database("mysql://testusr:[email protected]:3910/test");
    }

    string[string][] getHostname() {

        string[string][] data;

        auto conn = _db.getConnection();


foreach(row; conn.query("SELECT host_name FROM hosts_coll"))
        {
            string[string] host;
            host["HostName"] = row["host_name"];

            data ~= host;
        }

        conn.close();

        return data;
    }
}

```

Reply via email to