dbd/mysql/statement.c

changeset 32
03ed0ca09837
parent 30
8599f34c139b
child 33
6c64c45e7d8f
--- a/dbd/mysql/statement.c	Sat Jun 13 08:55:44 2009 +0000
+++ b/dbd/mysql/statement.c	Tue Sep 01 13:15:02 2009 +0000
@@ -402,6 +402,17 @@
     return 0;
 }
 
+/*
+ * __tostring
+ */
+static int statement_tostring(lua_State *L) {
+    statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_MYSQL_STATEMENT);
+
+    lua_pushfstring(L, "%s: %p", DBD_MYSQL_STATEMENT, statement);
+
+    return 1;
+}
+
 int dbd_mysql_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 
     unsigned long sql_len = strlen(sql_query);
 
@@ -456,6 +467,9 @@
     lua_pushcfunction(L, statement_gc);
     lua_setfield(L, -2, "__gc");
 
+    lua_pushcfunction(L, statement_tostring);
+    lua_setfield(L, -2, "__tostring");
+
     luaL_register(L, DBD_MYSQL_STATEMENT, statement_class_methods);
 
     return 1;    

mercurial