42 |
42 |
43 conn->mysql = mysql_init(NULL); |
43 conn->mysql = mysql_init(NULL); |
44 |
44 |
45 if (!mysql_real_connect(conn->mysql, host, user, password, db, port, unix_socket, client_flag)) { |
45 if (!mysql_real_connect(conn->mysql, host, user, password, db, port, unix_socket, client_flag)) { |
46 lua_pushnil(L); |
46 lua_pushnil(L); |
47 lua_pushfstring(L, "Failed to connect to database: %s", mysql_error(conn->mysql)); |
47 lua_pushfstring(L, DBI_ERR_CONNECTION_FAILED, mysql_error(conn->mysql)); |
48 return 2; |
48 return 2; |
49 } |
49 } |
50 |
50 |
51 luaL_getmetatable(L, DBD_MYSQL_CONNECTION); |
51 luaL_getmetatable(L, DBD_MYSQL_CONNECTION); |
52 lua_setmetatable(L, -2); |
52 lua_setmetatable(L, -2); |