dbd/postgresql/statement.c

changeset 32
03ed0ca09837
parent 30
8599f34c139b
child 33
6c64c45e7d8f
equal deleted inserted replaced
31:999ef93f0dbc 32:03ed0ca09837
348 statement_close(L); 348 statement_close(L);
349 349
350 return 0; 350 return 0;
351 } 351 }
352 352
353 /*
354 * __tostring
355 */
356 static int statement_tostring(lua_State *L) {
357 statement_t *statement = (statement_t *)luaL_checkudata(L, 1, DBD_POSTGRESQL_STATEMENT);
358
359 lua_pushfstring(L, "%s: %p", DBD_POSTGRESQL_STATEMENT, statement);
360
361 return 1;
362 }
363
353 int dbd_postgresql_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 364 int dbd_postgresql_statement_create(lua_State *L, connection_t *conn, const char *sql_query) {
354 statement_t *statement = NULL; 365 statement_t *statement = NULL;
355 ExecStatusType status; 366 ExecStatusType status;
356 PGresult *result = NULL; 367 PGresult *result = NULL;
357 char *new_sql; 368 char *new_sql;
424 lua_setfield(L, -2, "__index"); 435 lua_setfield(L, -2, "__index");
425 436
426 lua_pushcfunction(L, statement_gc); 437 lua_pushcfunction(L, statement_gc);
427 lua_setfield(L, -2, "__gc"); 438 lua_setfield(L, -2, "__gc");
428 439
440 lua_pushcfunction(L, statement_tostring);
441 lua_setfield(L, -2, "__tostring");
442
429 luaL_register(L, DBD_POSTGRESQL_STATEMENT, statement_class_methods); 443 luaL_register(L, DBD_POSTGRESQL_STATEMENT, statement_class_methods);
430 444
431 return 1; 445 return 1;
432 } 446 }

mercurial