dbd/mysql/connection.c

changeset 4
c50b0e6f25d6
parent 3
b61020ca4753
child 13
10c8c6f0da14
equal deleted inserted replaced
3:b61020ca4753 4:c50b0e6f25d6
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);
95 if (conn->mysql) { 95 if (conn->mysql) {
96 return dbd_mysql_statement_create(L, conn, luaL_checkstring(L, 2)); 96 return dbd_mysql_statement_create(L, conn, luaL_checkstring(L, 2));
97 } 97 }
98 98
99 lua_pushnil(L); 99 lua_pushnil(L);
100 lua_pushstring(L, "Database not available"); 100 lua_pushstring(L, DBI_ERR_DB_UNAVAILABLE);
101 101
102 return 2; 102 return 2;
103 } 103 }
104 104
105 /* 105 /*

mercurial