On 02/02/2017 07:10 AM, aberba wrote:

* Moreover, how do I close a connection or does it auto close?


It closes in its destructor (although AIUI there are times when dtors don't get run). But it can be closed manually with Connection.close();

* Does it support mysql_real_escape_string() like in php? This factor-in
the db encoding to do he appriate encoding for '/\" ...

There is a function like that one that was contributed, mysql.escape.mysql_escape:

https://github.com/Abscissa/mysql-native-experimental/blob/master/source/mysql/escape.d#L4

But, it's better to use prepared statements, because then no escaping is needed, and there's no worry about forgetting to escape:

Prepared prepared = prepare(connection, "SELECT * FROM `someTable` WHERE i=? AND s=?");
prepared.setArgs(7, "hello");
ResultRange results = prepared.query();

The prepared statement is reference counted and will automatically be released when there are no references to it left.

Reply via email to