Annotation of parser3/src/include/pa_sql_connection.h, revision 1.11

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.11    ! parser      8:        $Id: pa_sql_connection.h,v 1.10 2001/05/17 18:26: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.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.11    ! parser     56:                SQL_Driver_query_event_handlers& handlers) { 
1.9       parser     57:                fdriver.query(*fservices, fconnection, 
1.3       paf        58:                        statement, offset, limit, 
1.11    ! parser     59:                        handlers);
1.2       paf        60:        }
                     61: 
1.1       paf        62: 
                     63: private:
                     64: 
1.9       parser     65:        const String& furl;
1.1       paf        66:        SQL_Driver& fdriver;
1.9       parser     67:        SQL_Driver_services *fservices;
                     68:        void *fconnection;
1.10      parser     69:        time_t time_stamp;
1.1       paf        70: };
                     71: 
                     72: #endif

E-mail: