dbd/oracle/statement.c

changeset 32
03ed0ca09837
parent 31
999ef93f0dbc
equal deleted inserted replaced
31:999ef93f0dbc 32:03ed0ca09837
473 statement_close(L); 473 statement_close(L);
474 474
475 return 0; 475 return 0;
476 } 476 }
477 477
478 /*
479 * __tostring
480 */
481 static int statement_tostring(lua_State *L) {
482 statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_ORACLE_STATEMENT);
483
484 lua_pushfstring(L, "%s: %p", DBD_ORACLE_STATEMENT, statement);
485
486 return 1;
487 }
488
478 int dbd_oracle_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 489 int dbd_oracle_statement_create(lua_State *L, connection_t *conn, const char *sql_query) {
479 int rc; 490 int rc;
480 statement_t *statement = NULL; 491 statement_t *statement = NULL;
481 OCIStmt *stmt; 492 OCIStmt *stmt;
482 char *new_sql; 493 char *new_sql;
526 lua_setfield(L, -2, "__index"); 537 lua_setfield(L, -2, "__index");
527 538
528 lua_pushcfunction(L, statement_gc); 539 lua_pushcfunction(L, statement_gc);
529 lua_setfield(L, -2, "__gc"); 540 lua_setfield(L, -2, "__gc");
530 541
542 lua_pushcfunction(L, statement_tostring);
543 lua_setfield(L, -2, "__tostring");
544
531 luaL_register(L, DBD_ORACLE_STATEMENT, statement_class_methods); 545 luaL_register(L, DBD_ORACLE_STATEMENT, statement_class_methods);
532 546
533 return 1; 547 return 1;
534 } 548 }

mercurial