I tried making a test class and see if I can use this kind of syntax
Db.test();
class Db {
static MySQLClient client;
shared static this(){
client = new MySQLClient("");
}
static void test (string s=""){
auto conn = client.lockConnection();
int[] ids = [28, 4, 3, 5, 8, 13];
conn.execute("select name, email from users where id in " ~ ids.placeholders, ids, (MySQLRow row) {
writeln(row.name.peek!(char[]));
});
}
}
For some reason this works, but it executes twice, I can see output being written twice:
and when I press ctrl+C it shows an error that loops saying:
InvalidMemoryOperationError@src\core\exception.d(679): Invalid memory operation
Can you provide any other example on how you used this? aside from the void usedb() on the readme.
I wanted to wrap it inside a class so that other classes can use it as well without additional allocation
should I just go with?
auto db = new DB();
db.query("querying stuff");
but the "new" keyword always allocates, right?