Annotation of parser3/src/include/pa_sql_connection.h, revision 1.7
1.1 paf 1: /** @file
2: Parser: sql connection decl.
3:
4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
5:
6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.7 ! parser 8: $Id: pa_sql_connection.h,v 1.6 2001/05/17 08:42:22 parser Exp $
1.1 paf 9: */
10:
11: #ifndef PA_SQL_CONNECTION_H
12: #define PA_SQL_CONNECTION_H
13:
1.7 ! parser 14: #include "pa_config_includes.h"
1.1 paf 15: #include "pa_pool.h"
16: #include "pa_sql_driver.h"
1.4 paf 17: #include "pa_sql_driver_manager.h"
1.1 paf 18:
1.4 paf 19: /// SQL connection. handy wrapper around low level SQL_Driver
1.1 paf 20: class SQL_Connection : public Pooled {
21:
22: public:
23:
1.5 paf 24: void set_services(SQL_Driver_services *services) {
1.1 paf 25: fdriver.set_services(services);
26: }
27:
28: SQL_Connection(Pool& pool,
29: const String& aurl,
1.5 paf 30: SQL_Driver& adriver, SQL_Driver_services& services,
1.6 parser 31: char *used_only_in_constructor_url_cstr) : Pooled(pool),
1.1 paf 32: furl(aurl),
33: fdriver(adriver) {
34:
1.2 paf 35: set_services(&services); // associate with services[request]
1.6 parser 36: fdriver.connect(used_only_in_constructor_url_cstr, &connection);
1.1 paf 37: }
38:
39: void close() {
1.2 paf 40: set_services(0); // deassociate from services[request]
1.1 paf 41: SQL_driver_manager->close_connection(furl, *this);
42: }
43:
1.2 paf 44: void disconnect() { fdriver.disconnect(connection); }
45: void commit() { fdriver.commit(connection); }
46: void rollback() { fdriver.rollback(connection); }
1.3 paf 47: bool ping() { return fdriver.ping(connection); }
1.4 paf 48: uint quote(char *to, const char *from, unsigned int length) {
49: return fdriver.quote(connection, to, from, length);
50: }
51:
1.2 paf 52: void query(
1.3 paf 53: const char *statement, unsigned long offset, unsigned long limit,
1.2 paf 54: unsigned int *column_count, SQL_Driver::Cell **columns,
55: unsigned long *row_count, SQL_Driver::Cell ***rows) {
56: fdriver.query(connection,
1.3 paf 57: statement, offset, limit,
1.2 paf 58: column_count, columns,
59: row_count, rows);
60: }
61:
1.1 paf 62:
63: private:
64:
65: SQL_Driver& fdriver;
1.2 paf 66: void *connection;
1.1 paf 67: const String& furl;
68: };
69:
70: #endif
E-mail: