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

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:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      6: 
1.14    ! parser      7:        $Id: pa_sql_connection.h,v 1.13 2001/09/26 10:32:25 parser Exp $
1.1       paf         8: */
                      9: 
                     10: #ifndef PA_SQL_CONNECTION_H
                     11: #define PA_SQL_CONNECTION_H
                     12: 
1.7       parser     13: #include "pa_config_includes.h"
1.1       paf        14: #include "pa_pool.h"
                     15: #include "pa_sql_driver.h"
1.4       paf        16: #include "pa_sql_driver_manager.h"
1.1       paf        17: 
1.14    ! parser     18: /// SQL connection. handy wrapper around low level SQL_Driver
1.1       paf        19: class SQL_Connection : public Pooled {
                     20: 
                     21: public:
                     22: 
1.9       parser     23:        SQL_Connection(Pool& pool, const String& aurl, SQL_Driver& adriver) : Pooled(pool),
1.1       paf        24:                furl(aurl),
1.10      parser     25:                fdriver(adriver),
                     26:                fconnection(0),
                     27:                time_stamp(0) {
1.9       parser     28:        }
1.12      parser     29:        
                     30:        const String& url() { return furl; }
                     31: 
1.9       parser     32:        void set_services(SQL_Driver_services *aservices) {
1.10      parser     33:                time_stamp=time(0); // they started to use at this time
1.9       parser     34:                fservices=aservices;
1.1       paf        35:        }
1.10      parser     36:        bool expired(time_t older_dies) {
                     37:                return time_stamp<older_dies;
                     38:        }
1.1       paf        39: 
1.9       parser     40:        void close() {
                     41:                SQL_driver_manager->close_connection(furl, *this);
1.1       paf        42:        }
                     43: 
1.10      parser     44:        bool connected() { return fconnection!=0; }
1.9       parser     45:        void connect(char *used_only_in_connect_url_cstr) { 
                     46:                fdriver.connect(used_only_in_connect_url_cstr, *fservices, &fconnection);
                     47:        }
1.12      parser     48:        void disconnect() { fdriver.disconnect(fconnection); fconnection=0; }
1.9       parser     49:        void commit() { fdriver.commit(*fservices, fconnection); }
                     50:        void rollback() { fdriver.rollback(*fservices, fconnection); }
                     51:        bool ping() { return fdriver.ping(*fservices, fconnection); }
1.4       paf        52:        uint quote(char *to, const char *from, unsigned int length) {
1.9       parser     53:                return fdriver.quote(*fservices, fconnection, to, from, length);
1.4       paf        54:        }
                     55: 
1.2       paf        56:        void query(
1.3       paf        57:                const char *statement, unsigned long offset, unsigned long limit,
1.11      parser     58:                SQL_Driver_query_event_handlers& handlers) { 
1.9       parser     59:                fdriver.query(*fservices, fconnection, 
1.3       paf        60:                        statement, offset, limit, 
1.11      parser     61:                        handlers);
1.2       paf        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: