dbd/mysql/statement.c

changeset 32
03ed0ca09837
parent 30
8599f34c139b
child 33
6c64c45e7d8f
equal deleted inserted replaced
31:999ef93f0dbc 32:03ed0ca09837
400 statement_close(L); 400 statement_close(L);
401 401
402 return 0; 402 return 0;
403 } 403 }
404 404
405 /*
406 * __tostring
407 */
408 static int statement_tostring(lua_State *L) {
409 statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_MYSQL_STATEMENT);
410
411 lua_pushfstring(L, "%s: %p", DBD_MYSQL_STATEMENT, statement);
412
413 return 1;
414 }
415
405 int dbd_mysql_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 416 int dbd_mysql_statement_create(lua_State *L, connection_t *conn, const char *sql_query) {
406 unsigned long sql_len = strlen(sql_query); 417 unsigned long sql_len = strlen(sql_query);
407 418
408 statement_t *statement = NULL; 419 statement_t *statement = NULL;
409 420
454 lua_setfield(L, -2, "__index"); 465 lua_setfield(L, -2, "__index");
455 466
456 lua_pushcfunction(L, statement_gc); 467 lua_pushcfunction(L, statement_gc);
457 lua_setfield(L, -2, "__gc"); 468 lua_setfield(L, -2, "__gc");
458 469
470 lua_pushcfunction(L, statement_tostring);
471 lua_setfield(L, -2, "__tostring");
472
459 luaL_register(L, DBD_MYSQL_STATEMENT, statement_class_methods); 473 luaL_register(L, DBD_MYSQL_STATEMENT, statement_class_methods);
460 474
461 return 1; 475 return 1;
462 } 476 }

mercurial