PHP to D Conversion
zoujiaqing
zoujiaqing at gmail.com
Tue Oct 22 04:06:49 UTC 2019
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:xxxx@test.srv.com: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;
}
}
```
More information about the Digitalmars-d-learn
mailing list