Annotation of parser3/src/include/pa_sql_connection.h, revision 1.10
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.10 ! parser 8: $Id: pa_sql_connection.h,v 1.9 2001/05/17 13:23:28 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: }
30: void set_services(SQL_Driver_services *aservices) {
1.10 ! parser 31: time_stamp=time(0); // they started to use at this time
1.9 parser 32: fservices=aservices;
1.1 paf 33: }
1.10 ! parser 34: bool expired(time_t older_dies) {
! 35: return time_stamp<older_dies;
! 36: }
1.1 paf 37:
1.9 parser 38: void close() {
39: SQL_driver_manager->close_connection(furl, *this);
1.1 paf 40: }
41:
1.10 ! parser 42: bool connected() { return fconnection!=0; }
1.9 parser 43: void connect(char *used_only_in_connect_url_cstr) {
44: fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection);
45: }
1.10 ! parser 46: void disconnect() { fdriver.disconnect(*fservices, fconnection); fconnection=0; }
1.9 parser 47: void commit() { fdriver.commit(*fservices, fconnection); }
48: void rollback() { fdriver.rollback(*fservices, fconnection); }
49: bool ping() { return fdriver.ping(*fservices, fconnection); }
1.4 paf 50: uint quote(char *to, const char *from, unsigned int length) {
1.9 parser 51: return fdriver.quote(*fservices, fconnection, to, from, length);
1.4 paf 52: }
53:
1.2 paf 54: void query(
1.3 paf 55: const char *statement, unsigned long offset, unsigned long limit,
1.2 paf 56: unsigned int *column_count, SQL_Driver::Cell **columns,
57: unsigned long *row_count, SQL_Driver::Cell ***rows) {
1.9 parser 58: fdriver.query(*fservices, fconnection,
1.3 paf 59: statement, offset, limit,
1.2 paf 60: column_count, columns,
61: row_count, rows);
62: }
63:
1.1 paf 64:
65: private:
66:
1.9 parser 67: const String& furl;
1.1 paf 68: SQL_Driver& fdriver;
1.9 parser 69: SQL_Driver_services *fservices;
70: void *fconnection;
1.10 ! parser 71: time_t time_stamp;
1.1 paf 72: };
73:
74: #endif
E-mail: