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

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.5     ! paf         8:        $Id: pa_sql_connection.h,v 1.4 2001/04/05 13:19:41 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_SQL_CONNECTION_H
                     12: #define PA_SQL_CONNECTION_H
                     13: 
                     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.4       paf        18: /// SQL connection. handy wrapper around low level SQL_Driver
1.1       paf        19: class SQL_Connection : public Pooled {
                     20: 
                     21: public:
                     22: 
1.5     ! paf        23:        void set_services(SQL_Driver_services *services) {
1.1       paf        24:                fdriver.set_services(services);
                     25:        }
                     26: 
                     27:        SQL_Connection(Pool& pool,
                     28:                const String& aurl, 
1.5     ! paf        29:                SQL_Driver& adriver, SQL_Driver_services& services, 
1.1       paf        30:                char *url_cstr) : Pooled(pool),
                     31:                furl(aurl),
                     32:                fdriver(adriver) {
                     33: 
1.2       paf        34:                set_services(&services); // associate with services[request]
                     35:                fdriver.connect(url_cstr, &connection);
1.1       paf        36:        }
                     37: 
                     38:        void close() {
1.2       paf        39:                set_services(0); // deassociate from services[request]
1.1       paf        40:                SQL_driver_manager->close_connection(furl, *this);
                     41:        }
                     42: 
1.2       paf        43:        void disconnect() { fdriver.disconnect(connection); }
                     44:        void commit() { fdriver.commit(connection); }
                     45:        void rollback() { fdriver.rollback(connection); }
1.3       paf        46:        bool ping() { return fdriver.ping(connection); }
1.4       paf        47:        uint quote(char *to, const char *from, unsigned int length) {
                     48:                return fdriver.quote(connection, to, from, length);
                     49:        }
                     50: 
1.2       paf        51:        void query(
1.3       paf        52:                const char *statement, unsigned long offset, unsigned long limit,
1.2       paf        53:                unsigned int *column_count, SQL_Driver::Cell **columns,
                     54:                unsigned long *row_count, SQL_Driver::Cell ***rows) { 
                     55:                fdriver.query(connection, 
1.3       paf        56:                        statement, offset, limit, 
1.2       paf        57:                        column_count, columns,
                     58:                        row_count, rows);
                     59:        }
                     60: 
1.1       paf        61: 
                     62: private:
                     63: 
                     64:        SQL_Driver& fdriver;
1.2       paf        65:        void *connection;
1.1       paf        66:        const String& furl;
                     67: };
                     68: 
                     69: #endif

E-mail: