185 connection_close(L); |
185 connection_close(L); |
186 |
186 |
187 return 0; |
187 return 0; |
188 } |
188 } |
189 |
189 |
|
190 /* |
|
191 * __tostring |
|
192 */ |
|
193 static int connection_tostring(lua_State *L) { |
|
194 connection_t *conn = (connection_t *)luaL_checkudata(L, 1, DBD_MYSQL_CONNECTION); |
|
195 |
|
196 lua_pushfstring(L, "%s: %p", DBD_MYSQL_CONNECTION, conn); |
|
197 |
|
198 return 1; |
|
199 } |
|
200 |
190 int dbd_mysql_connection(lua_State *L) { |
201 int dbd_mysql_connection(lua_State *L) { |
191 static const luaL_Reg connection_methods[] = { |
202 static const luaL_Reg connection_methods[] = { |
192 {"autocommit", connection_autocommit}, |
203 {"autocommit", connection_autocommit}, |
193 {"close", connection_close}, |
204 {"close", connection_close}, |
194 {"commit", connection_commit}, |
205 {"commit", connection_commit}, |
210 lua_setfield(L, -2, "__index"); |
221 lua_setfield(L, -2, "__index"); |
211 |
222 |
212 lua_pushcfunction(L, connection_gc); |
223 lua_pushcfunction(L, connection_gc); |
213 lua_setfield(L, -2, "__gc"); |
224 lua_setfield(L, -2, "__gc"); |
214 |
225 |
|
226 lua_pushcfunction(L, connection_tostring); |
|
227 lua_setfield(L, -2, "__tostring"); |
|
228 |
215 luaL_register(L, DBD_MYSQL_CONNECTION, connection_class_methods); |
229 luaL_register(L, DBD_MYSQL_CONNECTION, connection_class_methods); |
216 |
230 |
217 return 1; |
231 return 1; |
218 } |
232 } |
219 |
233 |