Annotation of parser3/src/include/pa_sql_connection.h, revision 1.12
1.1 paf 1: /** @file
1.9 parser 2: Parser: sql fconnection decl.
1.1 paf 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.12 ! parser 8: $Id: pa_sql_connection.h,v 1.11 2001/07/23 11:19:25 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.9 parser 19: /// SQL fconnection. handy wrapper around low level SQL_Driver
1.1 paf 20: class SQL_Connection : public Pooled {
21:
22: public:
23:
1.9 parser 24: SQL_Connection(Pool& pool, const String& aurl, SQL_Driver& adriver) : Pooled(pool),
1.1 paf 25: furl(aurl),
1.10 parser 26: fdriver(adriver),
27: fconnection(0),
28: time_stamp(0) {
1.9 parser 29: }
1.12 ! parser 30:
! 31: const String& url() { return furl; }
! 32:
1.9 parser 33: void set_services(SQL_Driver_services *aservices) {
1.10 parser 34: time_stamp=time(0); // they started to use at this time
1.9 parser 35: fservices=aservices;
1.1 paf 36: }
1.10 parser 37: bool expired(time_t older_dies) {
38: return time_stamp<older_dies;
39: }
1.1 paf 40:
1.9 parser 41: void close() {
42: SQL_driver_manager->close_connection(furl, *this);
1.1 paf 43: }
44:
1.10 parser 45: bool connected() { return fconnection!=0; }
1.9 parser 46: void connect(char *used_only_in_connect_url_cstr) {
47: fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection);
48: }
1.12 ! parser 49: void disconnect() { fdriver.disconnect(fconnection); fconnection=0; }
1.9 parser 50: void commit() { fdriver.commit(*fservices, fconnection); }
51: void rollback() { fdriver.rollback(*fservices, fconnection); }
52: bool ping() { return fdriver.ping(*fservices, fconnection); }
1.4 paf 53: uint quote(char *to, const char *from, unsigned int length) {
1.9 parser 54: return fdriver.quote(*fservices, fconnection, to, from, length);
1.4 paf 55: }
56:
1.2 paf 57: void query(
1.3 paf 58: const char *statement, unsigned long offset, unsigned long limit,
1.11 parser 59: SQL_Driver_query_event_handlers& handlers) {
1.9 parser 60: fdriver.query(*fservices, fconnection,
1.3 paf 61: statement, offset, limit,
1.11 parser 62: handlers);
1.2 paf 63: }
64:
1.1 paf 65:
66: private:
67:
1.9 parser 68: const String& furl;
1.1 paf 69: SQL_Driver& fdriver;
1.9 parser 70: SQL_Driver_services *fservices;
71: void *fconnection;
1.10 parser 72: time_t time_stamp;
1.1 paf 73: };
74:
75: #endif
E-mail: