dbd/db2/statement.c

changeset 32
03ed0ca09837
parent 31
999ef93f0dbc
child 33
6c64c45e7d8f
equal deleted inserted replaced
31:999ef93f0dbc 32:03ed0ca09837
445 statement_close(L); 445 statement_close(L);
446 446
447 return 0; 447 return 0;
448 } 448 }
449 449
450 /*
451 * __tostring
452 */
453 static int statement_tostring(lua_State *L) {
454 statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_DB2_STATEMENT);
455
456 lua_pushfstring(L, "%s: %p", DBD_DB2_STATEMENT, statement);
457
458 return 1;
459 }
460
450 int dbd_db2_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 461 int dbd_db2_statement_create(lua_State *L, connection_t *conn, const char *sql_query) {
451 SQLRETURN rc = SQL_SUCCESS; 462 SQLRETURN rc = SQL_SUCCESS;
452 statement_t *statement = NULL; 463 statement_t *statement = NULL;
453 SQLHANDLE stmt; 464 SQLHANDLE stmt;
454 465
517 lua_setfield(L, -2, "__index"); 528 lua_setfield(L, -2, "__index");
518 529
519 lua_pushcfunction(L, statement_gc); 530 lua_pushcfunction(L, statement_gc);
520 lua_setfield(L, -2, "__gc"); 531 lua_setfield(L, -2, "__gc");
521 532
533 lua_pushcfunction(L, statement_tostring);
534 lua_setfield(L, -2, "__tostring");
535
522 luaL_register(L, DBD_DB2_STATEMENT, statement_class_methods); 536 luaL_register(L, DBD_DB2_STATEMENT, statement_class_methods);
523 537
524 return 1; 538 return 1;
525 } 539 }

mercurial