Changeset 42
- Timestamp:
- 01/05/07 16:28:01 (2 years ago)
- Files:
-
- trunk/dbi/mysql/MysqlDatabase.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dbi/mysql/MysqlDatabase.d
r40 r42 10 10 version (Ares) { 11 11 private static import std.regexp; 12 private import util.string : asString = toString; 12 private import util.string : toDString = toString; 13 private import util.string : toCString = toStringz; 13 14 debug (UnitTest) private import std.io.Console; 14 15 } else { 15 16 private static import std.string; 16 alias std.string.toString asString; 17 alias std.string.toString toDString; 18 alias std.string.toStringz toCString; 17 19 debug (UnitTest) private import std.stdio; 18 20 } … … 80 82 char[] host = "localhost"; 81 83 char[] dbname = "test"; 82 char[] sock = "/tmp/mysql.sock";84 char[] sock = null; 83 85 uint port = 0; 84 86 … … 113 115 } 114 116 115 mysql_real_connect(connection, host, username, password, dbname, port, sock, 0); 117 mysql_real_connect(connection, toCString(host), toCString(username), 118 toCString(password), toCString(dbname), port, 119 sock ? toCString(sock) : null, 0); 116 120 if (uint error = mysql_errno(connection)) { 117 121 throw new DBIException("Unable to connect to the MySQL database.", error, dbi.mysql.MysqlError.specificToGeneral(error)); … … 142 146 */ 143 147 override void execute (char[] sql) { 144 int error = mysql_real_query(connection, sql, sql.length);148 int error = mysql_real_query(connection, toCString(sql), sql.length); 145 149 if (error) { 146 150 throw new DBIException("Unable to execute a command on the MySQL database.", sql, error, dbi.mysql.MysqlError.specificToGeneral(error)); … … 161 165 */ 162 166 override MysqlResult query (char[] sql) { 163 mysql_real_query(connection, sql, sql.length);167 mysql_real_query(connection, toCString(sql), sql.length); 164 168 MYSQL_RES* results = mysql_store_result(connection); 165 169 //if (results is null) { … … 195 199 */ 196 200 deprecated override char[] getErrorMessage () { 197 return asString(mysql_error(connection));201 return toDString(mysql_error(connection)); 198 202 } 199 203
